startingNumberOfVMs = 1;
maxNumberOfVMs = 20; // maximum number of VMs you want
samplePercentThreshold = 0.7;
sampleDuration = TimeInterval_Minute * 3;
// Get the last sample
$sample = $CPUPercent.GetSamplePercent(sampleDuration);
// If the average CPU usage was more than 70%, increment the number of nodes
$TargetDedicated = ($sample > samplePercentThreshold ? startingNumberOfVMs + 1 : startingNumberOfVMs);
// Always keep the number of nodes between the starting number and the maximum
$TargetDedicated = max(startingNumberOfVMs, min($TargetDedicated, maxNumberOfVMs));
Azure batch autoscale formula

I'm trying to create a pool that always starts with 1 node. After 3 minutes of having more than 70% CPU usage the pool should generate another machine, and repeat. I'm using the current formula:
initialPoolSize = 1;
$TargetDedicatedNodes = initialPoolSize;
$totalDedicatedNodes =
(avg($CPUPercent.GetSample(TimeInterval_Minute * 3)) >= 0.7) ?
($TargetDedicatedNodes + 1) : $TargetDedicatedNodes;
I also tried using this formula that is posted in the Microsoft documentation:
initialPoolSize = 1;
$TargetDedicatedNodes = initialPoolSize;
$totalDedicatedNodes =
(min($CPUPercent.GetSample(TimeInterval_Minute * 3)) >= 0.7) ?
($CurrentDedicatedNodes * 1.1) : $CurrentDedicatedNodes;
Both formulas don't work, I'm stuck with only 1 node for the entire build time, and the CPU usage is at 100%.
If anyone has any experience with this and or can help that'll be greatly appreciated.
2 answers
Sort by: Most helpful
-
Sedat SALMAN 5,245 Reputation points
2023-05-25T05:09:23.7166667+00:00 -
Gal Hadar 0 Reputation points
2023-05-29T13:13:16.67+00:00 This is the answer for anyone wondering
maxNumberOfVMs = 20; // maximum number of VMs you want
samplePercentThreshold = 0.7;
sampleDuration = TimeInterval_Minute * 3;
// Get the last sample
$sample = (avg($CPUPercent.GetSample(sampleDuration)));
// If the average CPU usage was more than 70%, increase nodes by one, if not true keeps as is
$TargetDedicated = ($sample >= samplePercentThreshold ? $TargetDedicated +1 : $TargetDedicated);
// If the average CPU usage is below 20% decrease nodes by one, if not true keep as is
$TargetDedicated = ($sample <= 0.2 ? $TargetDedicated - 1 : $TargetDedicated);
// Always keep the number of nodes under the maximum
$TargetDedicated = min($TargetDedicated, maxNumberOfVMs);