This commit is contained in:
Yunlong Zhang 2017-04-19 18:37:53 -07:00
Родитель 42ac49a4eb
Коммит b99b9d2496
2 изменённых файлов: 6 добавлений и 4 удалений

Просмотреть файл

@ -1,7 +1,8 @@
// This autoscale formula sets the pool size to a certain number of nodes for an initial time period. Then it adjusts the pool size based on the number of running and active tasks after the initial time period has elapsed.
// Sets the initial pool size to 4 nodes.
$TargetDedicated = 4;
initialPoolSize = 4;
$TargetDedicated = initialPoolSize;
// "Mon, 06 Oct 2014 10:20:00 GMT" represents the datetime that this autoscale formula starts to evaluate. This is an arbitrary value here.
lifespan = time() - time(\"Mon, 06 Oct 2014 10:20:00 GMT\");
// Representing 60 minutes
@ -13,4 +14,4 @@ ratio = 50;
// After 10 minutes, obtains the max value of the number of running and active tasks within the past 60 minutes.
// If both values are 0 (indicating that no tasks were running or active in the last 60 minutes), the pool size is set to 0.
// If either value is greater than zero, no change is made.
$TargetDedicated = (lifespan > startup ? (max($RunningTasks.GetSample(span, ratio), $ActiveTasks.GetSample(span, ratio)) == 0 ? 0 : $TargetDedicated) : 4);
$TargetDedicated = (lifespan > startup ? (max($RunningTasks.GetSample(span, ratio), $ActiveTasks.GetSample(span, ratio)) == 0 ? 0 : $TargetDedicated) : initialPoolSize );

Просмотреть файл

@ -5,8 +5,9 @@ $samples = $ActiveTasks.GetSamplePercent(TimeInterval_Minute * 15);
// If we have fewer than 70 percent data points, we use the last sample point, otherwise we use the maximum of last sample point and the history average.
$tasks = $samples < 70 ? max(0, $ActiveTasks.GetSample(1)) : max( $ActiveTasks.GetSample(1), avg($ActiveTasks.GetSample(TimeInterval_Minute * 15)));
// If number of pending tasks is not 0, set targetVM to pending tasks, otherwise half of current dedicated.
$targetVMs = $tasks > 0? $tasks:max(0, $TargetDedicated / 2);
$targetVMs = $tasks > 0 ? $tasks : max(0, $TargetDedicated / 2);
// The pool size is capped at 20, if target VM value is more than that, set it to 20. This value should be adjusted according to your use case.
$TargetDedicated = max(0, min($targetVMs, 20));
cappedPoolSize = 20;
$TargetDedicated = max(0, min($targetVMs, cappedPoolSize));
// Set node deallocation mode - keep nodes active only until tasks finish
$NodeDeallocationOption = taskcompletion;