Create a scaling rule

Last Updated: Nov 08, 2017

A scaling rule defines specific scaling actions, for example, adding or removing n ECS instances.

If the execution of a scaling rule results in a number of ECS instances in the scaling group that is less than the MinSize or greater than the MaxSize, Auto Scaling automatically adjusts the number of ECS instances to be added or removed by executing the “Adjust scaling group instance quantity to MinSize” or “Adjust scaling group instance quantity to MaxSize” rule.

  • Example 1: If a scaling group has a MaxSize of 3, the current number of instances (Total Capacity) is 2, and a scaling rule instructs the system to “add 3 ECS instances”, this operation actually only adds one ECS instance. (The values in the scaling rule are not changed.)
  • Example 2: If a scaling group has a MinSize of 2, the current number of instances (Total Capacity) is 3, and a scaling rule instructs the system to “remove 5 ECS instances”, this operation actually only removes one ECS instance. (The values in the scaling rule are not changed.)

Description

This operation creates a scaling rule according to input parameters.

  • When AdjustmentType is TotalCapaciy, the quantity of ECS instances in the current scaling group is adjusted to the specified value, and the corresponding AdjustmentValue must be no less than 0.

  • When AdjustmentType is QuantityChangeInCapacity or PercentChangeInCapacity, if the corresponding AdjustmentValue is a positive number, additional ECS instances are increased; if the corresponding AdjustmentValue is a negative number, ECS instances are decreased.

  • When AdjustmentType is PercentChangeInCapacity, the Auto Scaling service uses the formula: current number of instances (Total Capacity) * AdjustmentValue/100 and follow standard rounding principles to confirm the number of ECS instances to be added or removed.

  • When a cool-down time (Cooldown) is specified in a scaling rule, the specified Cooldown is applied to the scaling group after the scaling activity to perform this rule is completed. Otherwise, the DefaultCooldown is applied to the scaling group.

  • A maximum of 10 scaling rules can be created in a scaling group.

  • The only identifier of a scaling rule returned (ScalingRuleAri) can be primarily used by the following interfaces:

    • By specifying the ExecuteScalingRule’s ScalingRuleAri parameter, you can manually perform a scaling rule.
    • By specifying the CreateScheduledTask’s ScheduledAction parameter, you can schedule the performing of a scaling rule.

Request parameters

Name Type Required? Description
Action String Yes Operation interface, required. The parameter value is CreateScalingRule.
ScalingGroupId String Yes ID of the scaling group of a scaling rule.
AdjustmentType String Yes Adjustment mode of a scaling rule. Optional values:
- QuantityChangeInCapacity: It is used to increase or decrease a specified number of ECS instances.
- PercentChangeInCapacity: It is used to increase or decrease a specified proportion of ECS instances.
- TotalCapacity: It is used to adjust the quantity of ECS instances in the current scaling group to a specified value.
AdjustmentValue Integer Yes Adjusted value of a scaling rule. Value range:
- QuantityChangeInCapacity: (0, 100] U (-100, 0]
- PercentChangeInCapacity: [0, 10000] U [-10000, 0]
- TotalCapacity: [0, 100]
ScalingRuleName String No Name shown for the scaling group, which is a string containing 2 to 40 English or Chinese characters. It must begin with a number, a letter (case-insensitive) or a Chinese character and can contain numbers, “_”, “-“ or “.”. The account name in the same scaling group is unique in the same region. If this parameter value is not specified, the default value is ScalingRuleId.
Cooldown Integer No Cool-down time of a scaling rule. Value range: [0, 86,400], in seconds. The default value is empty.

Return parameters

Name Type Description
ScalingRuleId String ID of a scaling rule, generated by the system and globally unique.
ScalingRuleAri String Unique identifier of a scaling rule.

Error code

For errors common to all interfaces, see Client Error Table or Server Error Table.

Error Error code Description HTTP status code
The specified scaling group does not exist in this account. InvalidScalingGroupId.NotFound The specified scaling group does not exist. 404
The scaling rule name already exists. InvalidScalingRuleName.Duplicate The specified value of parameter <parameter name> is duplicated. 400
Scaling rule quantity exceeds the upper limit for a user to use. QuotaExceeded.ScalingRule Scaling rule quota exceeded in the specified scaling group. 400

Example

Request example
  1. http://ess.aliyuncs.com/?Action=CreateScalingRule
  2. &ScalingGroupId=AG6CQdPU8OKdwLjgZcJ2eaQ
  3. &AdjustmentType=QuantityChangeInCapacity
  4. &AdjustmentValue=-10
  5. &<Public Request Parameters>
Return example

XML format:

  1. <CreateScalingRuleResponse>
  2. <ScalingRuleAri>
  3. ari:acs:ess:cn-qingdao:1344371:scalingrule/eMKWG8SRNb9dBLAjweNI1Ik
  4. </ScalingRuleAri>
  5. <ScalingRuleId>eMKWG8SRNb9dBLAjweNI1Ik</ScalingRuleId>
  6. <RequestId>570C84F4-A434-488A-AFA1-1E3213682B33</RequestId>
  7. </CreateScalingRuleResponse>

JSON format:

  1. {
  2. "RequestId": "04F0F334-1335-436C-A1D7-6C044FE73368",
  3. "ScalingRuleId": "eMKWG8SRNb9dBLAjweNI1Ik",
  4. "ScalingRuleAri":"ari:acs:ess:cn-qingdao:1344371:scalingrule/eMKWG8SRNb9dBLAjweNI1Ik"
  5. }
Thank you! We've received your feedback.