added some description and constants

This commit is contained in:
Yunlong Zhang 2017-04-19 17:48:59 -07:00
Родитель 95e080bdc0
Коммит 82a577d99a
4 изменённых файлов: 27 добавлений и 4 удалений

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

@ -1,11 +1,16 @@
// This is another example that adjusts the pool size based on the number of tasks. This formula also takes into account the MaxTasksPerComputeNode value that has been set for the pool. This is particularly useful in situations where parallel task execution has been enabled on your pool.
// Determine whether 70 percent of the samples have been recorded in the past 15 minutes; if not, use last sample
$samples = $ActiveTasks.GetSamplePercent(TimeInterval_Minute * 15);
$tasks = $samples < 70 ? max(0,$ActiveTasks.GetSample(1)) : max( $ActiveTasks.GetSample(1),avg($ActiveTasks.GetSample(TimeInterval_Minute * 15)));
percentage = 70;
span = TimeInterval_Minute * 15;
$samples = $ActiveTasks.GetSamplePercent(span );
$tasks = $samples < percentage ? max(0,$ActiveTasks.GetSample(1)) : max( $ActiveTasks.GetSample(1), avg($ActiveTasks.GetSample(span)));
// Set the number of nodes to add to one-fourth the number of active tasks (the MaxTasksPerComputeNode property on this pool is set to 4, adjust this number for your use case)
multiplier = 0.25;
$cores = $TargetDedicated * 4;
$extraVMs = (($tasks - $cores) + 3) / 4;
$extraVMs = (($tasks - $cores) + 3) * multiplier;
$targetVMs = ($TargetDedicated + $extraVMs);
// Attempt to grow the number of compute nodes to match the number of active tasks, with a maximum of 3
$TargetDedicated = max(0,min($targetVMs,3));
$TargetDedicated = max(0, min($targetVMs, 3));
// Keep the nodes active until the tasks finish
$NodeDeallocationOption = taskcompletion;

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

@ -1,6 +1,16 @@
// 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;
// "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
span = TimeInterval_Minute * 60;
// Representing 10 minutes
startup = TimeInterval_Minute * 10;
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);

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

@ -1,3 +1,5 @@
// In this example, the pool size is adjusted based on the number of tasks in the queue. Note that both comments and line breaks are acceptable in formula strings.
// Get pending tasks for the past 15 minutes.
$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.

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

@ -1,5 +1,11 @@
// Perhaps you want to adjust the pool size based on the day of the week and time of day, to increase or decrease the number of nodes in the pool accordingly.
// This formula first obtains the current time. If it's a weekday (1-5) and within working hours (8 AM to 6 PM), the target pool size is set to 20 nodes. Otherwise, it's set to 10 nodes.
$curTime = time();
// Check current time is within working hours (8 AM to 6 PM) or not
$workHours = $curTime.hour >= 8 && $curTime.hour < 18;
// Check current day is a weekday (Monday to Friday) or not
$isWeekday = $curTime.weekday >= 1 && $curTime.weekday <= 5;
$isWorkingWeekdayHour = $workHours && $isWeekday;
// Set target pool size to 20 nodes if it's between 8 AM and 6 PM in weekday, otherwise set to 10 nodes
$TargetDedicated = $isWorkingWeekdayHour ? 20:10;