Skip to content
This repository was archived by the owner on Oct 12, 2023. It is now read-only.

Commit 7192e08

Browse files
authored
Feature: Added Queue/Running Autoscale Formula (#316)
* Added autoscale for queue and running * Updated documentation from comments
1 parent 844ebde commit 7192e08

File tree

2 files changed

+31
-4
lines changed

2 files changed

+31
-4
lines changed

R/autoscale.R

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,19 @@ autoscaleQueueFormula <- paste0(
2525
"max( $ActiveTasks.GetSample(1), avg($ActiveTasks.GetSample(TimeInterval_Minute * 15)));",
2626
"$maxTasksPerNode = %s;",
2727
"$round = $maxTasksPerNode - 1;",
28-
"$targetVMs = $tasks > 0? (($tasks + $round)/ $maxTasksPerNode) : max(0, $TargetDedicated/2) + 0.5;",
28+
"$targetVMs = $tasks > 0 ? (($tasks + $round) / $maxTasksPerNode) : max(0, $TargetDedicated/2) + 0.5;",
29+
"$TargetDedicatedNodes = max(%s, min($targetVMs, %s));",
30+
"$TargetLowPriorityNodes = max(%s, min($targetVMs, %s));",
31+
"$NodeDeallocationOption = taskcompletion;"
32+
)
33+
34+
autoscaleQueueAndRunningFormula <- paste0(
35+
"$samples = $PendingTasks.GetSamplePercent(TimeInterval_Minute * 15);",
36+
"$tasks = $samples < 70 ? max(0,$PendingTasks.GetSample(1)) : ",
37+
"max( $PendingTasks.GetSample(1), avg($PendingTasks.GetSample(TimeInterval_Minute * 15)));",
38+
"$maxTasksPerNode = %s;",
39+
"$round = $maxTasksPerNode - 1;",
40+
"$targetVMs = $tasks > 0 ? (($tasks + $round) / $maxTasksPerNode) : max(0, $TargetDedicated/2) + 0.5;",
2941
"$TargetDedicatedNodes = max(%s, min($targetVMs, %s));",
3042
"$TargetLowPriorityNodes = max(%s, min($targetVMs, %s));",
3143
"$NodeDeallocationOption = taskcompletion;"
@@ -35,7 +47,8 @@ autoscaleFormula <- list(
3547
"WEEKEND" = autoscaleWeekendFormula,
3648
"WORKDAY" = autoscaleWorkdayFormula,
3749
"MAX_CPU" = autoscaleMaxCpuFormula,
38-
"QUEUE" = autoscaleQueueFormula
50+
"QUEUE" = autoscaleQueueFormula,
51+
"QUEUE_AND_RUNNING" = autoscaleQueueAndRunningFormula
3952
)
4053

4154
getAutoscaleFormula <-
@@ -68,8 +81,20 @@ getAutoscaleFormula <-
6881
)
6982
)
7083
}
84+
else if (formulaName == formulas[5]) {
85+
return(
86+
sprintf(
87+
autoscaleQueueAndRunningFormula,
88+
maxTasksPerNode,
89+
dedicatedMin,
90+
dedicatedMax,
91+
lowPriorityMin,
92+
lowPriorityMax
93+
)
94+
)
95+
}
7196
else{
72-
stop("Incorrect autoscale formula: QUEUE, MAX_CPU, WEEKEND, WORKDAY")
97+
stop("Incorrect autoscale formula: QUEUE, QUEUE_AND_RUNNING, MAX_CPU, WEEKEND, WORKDAY")
7398
}
7499
}
75100

docs/32-autoscale.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ This package pre-defines a few autoscale options (or *autoscale formulas*) that
66

77
The options are:
88
- "QUEUE"
9+
- "QUEUE_AND_RUNNING"
910
- "WORKDAY"
1011
- "WEEKEND"
1112
- "MAX_CPU"
@@ -36,11 +37,12 @@ By default, doAzureParallel uses autoscale and uses the QUEUE autoscale formula.
3637

3738
## Autoscale Formulas:
3839

39-
For four autoscale settings are can be selected for different scenarios:
40+
For five autoscale settings are can be selected for different scenarios:
4041

4142
| Autoscale Formula | Description |
4243
| ----------------- |:----------- |
4344
| QUEUE | This formula will scale up and down the pool size based on the amount of work in the queue |
45+
| QUEUE_AND_RUNNING | This formula will scale up and down the pool size based on the amount of running tasks and active tasks in the queue |
4446
| WORKDAY | This formula will adjust your pool size based on the day/time of the week. If it's a weekday, during working hours (8am - 6pm), the pool size will increase to maximum size (maxNodes). Otherwise it will default to the minimum size (minNodes). |
4547
| WEEKEND | This formula will adjust your pool size based on the day/time of the week. At the beginning of the weekend (Saturday), the pool size will increase to maximum size (maxNodes). At the end of Sunday, the pool will shrink down to the minimum size (minNodes). |
4648
| MAX_CPU | This formula will adjust your pool size based on the minimum average CPU usage during the last 10 minutes - if the minimum average CPU usage was above 70%, the cluster size will increase 1.1X times. |

0 commit comments

Comments
 (0)