Nomad
Target Value Strategy Plugin
The target-value
strategy plugin performs count calculations in order to
keep the value resulting from the APM query at or around a specified target.
It accomplishes this by extrapolating the current metric value and used capacity linearly to determine if a scaling action is required and how many instances need to be added or removed. More specify, the new scaling value is calculated as:
factor = current_metric_value / target
new_count = factor * current_count
As an example, a policy that tracks memory usage with target defined as 70
(representing 70% of memory usage) and in a scenario where there are 10
instances running will generate a scaling action with scaling factor of
1.1428571429
, which will add 2
new instances when the metric reaches 80
(80% of memory usage) because:
factor = 80/70 = 1.1428571429
new_count = 1.1428571429 * 10 ~= 12
In other words, if with 10 instances the memory usage in 80%, it's expected that with 12 instances the memory usage will be lower and closer to the target value of 70%.
This means that this strategy expects your infrastructure to have the following characteristics:
inverse relationship between metric and number of instances, meaning that adding more instances will cause your metric value to go down.
linear response to infrastructure changes, meaning that a 2x increase in instance count will cut the metric value approximately in half.
Note: These properties may not be true for your infrastructure. Make sure you have a good grasp of your query result dynamic as the number of instances changes.
To fine-tune scaling decisions you can adjust the threshold
configuration.
This value defines a range between 1 ± threshold
where scaling actions with a
scaling factor within this range are ignored. For example, with the default
value of 0.01
only scaling actions with a factor lower than 0.99
and larger
than 1.01
are taken into account.
With a low threshold
you are expected to observe more scaling actions with
smaller changes, while a high threshold
value is expected to generate fewer
scaling actions with bigger changes in count.
Since threshold
is compared against the computed scaling factor, and the
factor is based on your expected metric values and specified target
,
adjusting the threshold
value can take some time and a few trial and error
attempts.
Agent Configuration Options
strategy "target-value" {
driver = "target-value"
}
Policy Configuration Options
check "target-value-check" {
# ...
strategy "target-value" {
target = 20
threshold = 0.0001
}
# ...
}
target
(float: <required>)
- Specifies the metric value the Autoscaler should try to meet.threshold
(float: 0.01)
- Specifies how significant a change in the input metric should be considered. Small threshold values can lead to output fluctuation.max_scale_up
(int: unlimited)
- Specifies the maximum number of instances that can be added in a single scaling operation. It acts as a safeguard against the system scaling up too rapidly.max_scale_down
(int: unlimited)
- Specifies the maximum number of instances that can be removed in a single scaling operation. It acts as a safeguard against the system scaling down too rapidly.