The function of a scaling rule is determined by its type, which can be used to trigger a scaling activity or intelligently set the boundary values of a scaling group. Depending on your business requirements, you can invoke the CreateScalingRule API to create different types of scaling rules. For example, if your business only requires setting the boundary values of a scaling group, we recommend that you select the predictive rule type.
Operation description
A scaling rule defines specific scale-out or scale-in operations, such as adding or removing N instances. If executing a scaling rule would cause the number of ECS or ECI instances in the scaling group to fall below MinSize or exceed MaxSize, automatic scaling automatically adjusts the number of ECS or ECI instances to be added or removed so that the actual instance count reaches MinSize or MaxSize. However, the configured value of the scaling rule remains unchanged. Examples are as follows:
For a scaling group with MaxSize=3 and a current Total Capacity of 2, if the scaling rule specifies adding 3 ECS instances, only 1 ECS instance will actually be added during execution, but the configured value of the scaling rule remains 3.
For a scaling group with MinSize=2 and a current Total Capacity of 3, if the scaling rule specifies removing 5 ECS instances, only 1 ECS instance will actually be removed during execution, but the configured value of the scaling rule remains 5.
Please note the following parameter-related descriptions:
When AdjustmentType is TotalCapacity, it means adjusting the current number of ECS or ECI instances in the scaling group to the specified quantity. The corresponding AdjustmentValue must be greater than or equal to 0.
When AdjustmentType is QuantityChangeInCapacity or PercentChangeInCapacity, a positive AdjustmentValue indicates adding instances, while a negative value indicates removing instances.
When AdjustmentType is PercentChangeInCapacity, the automatic scaling service calculates the number of ECS or ECI instances to add or remove by multiplying the current instance count (Total Capacity) by AdjustmentValue/100 and then applying rounding.
If a cooldown time (Cooldown) is specified in the scaling rule, the scaling group enters a cooldown period for the specified duration after the scaling activity triggered by this rule completes. If no cooldown time is specified in the scaling rule, the default cooldown time (DefaultCooldown) of the scaling group is used.
There is a limit on the number of scaling rules that can be created within a single scaling group. For details, see Limits.
- The returned Unique Identifier (ScalingRuleAri) of the scaling rule can be used with the following APIs:
Specify it in the ScalingRuleAri parameter when invoking ExecuteScalingRule to manually execute the scaling rule.
Specify it in the ScheduledAction parameter when creating a scheduled task (CreateScheduledTask) to execute the scaling rule at a scheduled time.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
ess:CreateScalingRule |
create |
*ScalingGroup
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| ScalingGroupId |
string |
Yes |
The ID of the scaling group to which the scaling rule belongs. |
asg-bp1ffogfdauy0jw0**** |
| ScalingRuleName |
string |
No |
The name of the scaling rule. The name must be 2 to 64 characters in length, and can contain letters, digits, underscores (_), hyphens (-), and periods (.). The name must start with a letter or a digit. The name of each scaling rule must be unique under the same account within a region. If you leave this parameter empty, the scaling rule ID is used. |
scalingrule**** |
| Cooldown |
integer |
No |
The cooldown time of the scaling rule. This parameter is available only if you set the ScalingRuleType parameter to SimpleScalingRule. Valid values: 0 to 86400. Unit: seconds. By default, this parameter is left empty. |
60 |
| MinAdjustmentMagnitude |
integer |
No |
The minimum number of instances that must be scaled when the AdjustmentType parameter is set to PercentChangeInCapacity. This parameter takes effect only if you set the ScalingRuleType parameter to SimpleScalingRule or StepScalingRule. |
1 |
| AdjustmentType |
string |
No |
The scaling method of the scaling rule. This parameter is required only if you set the ScalingRuleType parameter to SimpleScalingRule or StepScalingRule. Valid values:
|
QuantityChangeInCapacity |
| AdjustmentValue |
integer |
No |
The number of instances that must be scaled based on the scaling rule. This parameter is required only if you set the ScalingRuleType parameter to SimpleScalingRule or StepScalingRule. The number of ECS instances that are scaled in a single scaling activity cannot exceed 1,000.
|
100 |
| ScalingRuleType |
string |
No |
The type of the scaling rule. Valid values:
Default value: SimpleScalingRule. |
SimpleScalingRule |
| EstimatedInstanceWarmup |
integer |
No |
The warmup period of an instance. This parameter is available only if you set the ScalingRuleType parameter to TargetTrackingScalingRule or PredictiveScalingRule. Auto Scaling adds ECS instances that are in the warmup state to a scaling group but does not report monitoring data to CloudMonitor during the warmup period. Note
Auto Scaling calculates the number of ECS instances that must be scaled. ECS instances in the warmup state are not counted towards the current capacity of the scaling group. Valid values: 0 to 86400. Unit: seconds. Default value: 300. |
300 |
| MetricName |
string |
No |
The predefined metric that you want to monitor. If you set ScalingRuleType to TargetTrackingScalingRule or PredictiveScalingRule, you must specify this parameter. Valid values if you set ScalingRuleType to TargetTrackingScalingRule:
Valid values if you set ScalingRuleType to PredictiveScalingRule:
For more information, see Event-triggered tasks of the system monitoring type. |
CpuUtilization |
| TargetValue |
number |
No |
The target value. This parameter is required only if you set the ScalingRuleType parameter to TargetTrackingScalingRule or PredictiveScalingRule. The value must be greater than 0 and can have up to three decimal places. |
0.125 |
| DisableScaleIn |
boolean |
No |
Specifies whether to disable scale-in. This parameter is available only if you set ScalingRuleType to TargetTrackingScalingRule. Default value: false. |
false |
| ScaleInEvaluationCount |
integer |
No |
The number of consecutive times that the event-triggered task created for scale-in activities must meet the threshold conditions before an alert is triggered. After a target tracking scaling rule is created, an event-triggered task is automatically created and then associated with the target tracking scaling rule. Default value: 15. |
15 |
| ScaleOutEvaluationCount |
integer |
No |
The number of consecutive times that the event-triggered task created for scale-out activities must meet the threshold conditions before an alert is triggered. After a target tracking scaling rule is created, an event-triggered task is automatically created and then associated with the target tracking scaling rule. Default value: 3. |
3 |
| PredictiveScalingMode |
string |
No |
The mode of the predictive scaling rule. Valid values:
Default value: PredictAndScale. |
PredictAndScale |
| PredictiveValueBehavior |
string |
No |
The maximum value for predication tasks. Valid values:
Default value: MaxOverridePredictiveValue. |
MaxOverridePredictiveValue |
| PredictiveValueBuffer |
integer |
No |
The ratio based on which the predicted value is increased when you set Default value: 0. |
50 |
| PredictiveTaskBufferTime |
integer |
No |
The amount of buffer time before the prediction task is executed. By default, all prediction tasks that are automatically created for a predictive scaling rule are executed on the hour. You can specify an amount of buffer time for resource preparation before the prediction tasks are executed. Valid values: 0 to 60. Unit: minutes. Default value: 0. |
30 |
| InitialMaxSize |
integer |
No |
The maximum number of ECS instances that can be contained in the scaling group. If you specify InitialMaxSize, you must specify The default value of this parameter is the value of MaxSize. |
100 |
| StepAdjustments |
array<object> |
No |
Details of the step adjustments. |
|
|
object |
No |
Details of the step adjustments. |
||
| MetricIntervalUpperBound |
number |
No |
The upper limit that is specified in a step adjustment. Valid values: -9.999999E18 to 9.999999E18. |
5.0 |
| ScalingAdjustment |
integer |
No |
The number of ECS instances that you want to scale in a step adjustment. This parameter is available only if you set the ScalingRuleType parameter to StepScalingRule. |
1 |
| MetricIntervalLowerBound |
number |
No |
The lower limit specified in a step adjustment. This parameter is available only if you set the ScalingRuleType parameter to StepScalingRule. Valid values: -9.999999E18 to 9.999999E18. |
1.0 |
| RegionId |
string |
No |
The region ID of the scaling group. |
cn-hangzhou |
| AlarmDimensions |
array<object> |
No |
The metric dimensions. This parameter is applicable to target tracking scaling rules. If your predefined metric requires extra dimensions, you must specify this parameter. For example, if you use LoadBalancerRealServerAverageQps as your predefined metric, you must use this parameter to specify the rulePool dimension. |
|
|
object |
No |
Dimension information values for monitoring metrics. This parameter applies to target tracking rules and is used when additional dimension information is required for a metric. For example, the LoadBalancerRealServerAverageQps metric requires specifying the rulePool dimension key-value pair. |
||
| DimensionKey |
string |
No |
The dimension key of the metric. |
rulePool |
| DimensionValue |
string |
No |
The dimension value of the metric. |
sgp-l1cbirz451yxuxxx |
| MetricType |
string |
No |
The metric type. Valid values:
|
system |
| HybridMonitorNamespace |
string |
No |
The ID of the Hybrid Cloud Monitoring namespace. For information about how to manage Hybrid Cloud Monitoring namespaces, see Manage namespaces. |
aliyun-test |
| HybridMetrics |
array<object> |
No |
The Hybrid Cloud Monitoring metrics. For more information, see Create a custom target tracking scaling rule. |
|
|
array<object> |
No |
|||
| Id |
string |
No |
The reference ID of the metric in the metric expression. |
a |
| Expression |
string |
No |
The metric expression that consists of multiple Hybrid Cloud Monitoring metrics. It calculates a result used to trigger scaling events. The expression must be written in Reverse Polish Notation (RPN) format and supports only the following operators: |
(a+b)/2 |
| MetricName |
string |
No |
The name of the Hybrid Cloud Monitoring metric. |
AliyunSmq_NumberOfMessagesVisible |
| Statistic |
string |
No |
The statistical method of the metric value. Valid values:
|
Average |
| Dimensions |
array<object> |
No |
The metric dimensions. You can use this parameter to specify the monitored resources. |
|
|
object |
No |
|||
| DimensionKey |
string |
No |
The key of the metric dimension. |
queue |
| DimensionValue |
string |
No |
The value of the metric dimension. |
testQueue |
| AlarmOptions |
object |
No |
Definition of alerting properties. |
|
| Period |
integer |
No |
The period for aggregating monitoring metric data in a target tracking rule, in seconds. Valid values:
Note
Default Value: 60. |
60 |
Response elements
|
Element |
Type |
Description |
Example |
|
object |
|||
| ScalingRuleAri |
string |
The unique identifier of the scaling rule. |
ari:acs:ess:cn-hangzhou:140692647406****:scalingrule/asr-bp1dvirgwkoowxk7**** |
| RequestId |
string |
The ID of the request. |
473469C7-AA6F-4DC5-B3DB-A3DC0DE3**** |
| ScalingRuleId |
string |
The ID of the scaling rule, which is generated by the system and is globally unique. |
asr-bp1dvirgwkoowxk7**** |
Examples
Success response
JSON format
{
"ScalingRuleAri": "ari:acs:ess:cn-hangzhou:140692647406****:scalingrule/asr-bp1dvirgwkoowxk7****",
"RequestId": "473469C7-AA6F-4DC5-B3DB-A3DC0DE3****",
"ScalingRuleId": "asr-bp1dvirgwkoowxk7****"
}
Error codes
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.