This topic describes how to create a scaling rule. A scaling rule can be used to trigger a scaling activity or set the minimum and maximum numbers of Elastic Compute Service (ECS) instances for a scaling group.

Background information

The following table describes the scaling rule types supported by Auto Scaling.
Type Purpose Description
Simple scaling rule A simple scaling rule is used to trigger a scaling activity. You can specify a simple scaling rule to increase or decrease the number of ECS instances in a scaling group by or to a specific number.
Target tracking scaling rule A target tracking scaling rule is used to trigger a scaling activity. When you create a target tracking scaling rule, you must select a Cloud Monitor metric and set a target value. Auto Scaling automatically calculates the number of ECS instances required to keep the metric close to the target value, and scales ECS instances accordingly.
Note After you create a target tracking scaling rule, Auto Scaling automatically creates an event-triggered task and associates this task with the target tracking scaling rule. A target tracking scaling rule can be triggered only by its associated event-triggered task.
Predictive scaling rule A predictive scaling rule is used to intelligently set the minimum and maximum numbers of ECS instances for a scaling group. After a predictive scaling rule is executed, Auto Scaling analyzes historical monitoring data of a scaling group to predict the values of specified metrics through machine learning. Auto Scaling can also automatically create scheduled tasks to help set the optimal minimum and maximum numbers of ECS instances for the scaling group.
Note A predictive scaling rule changes only the minimum and maximum numbers of ECS instances for a scaling group, but does not scale ECS instances in the scaling group.
Step scaling rule A step scaling rule is used to trigger a scaling activity. When you create a step scaling rule, you must associate an event-triggered task with the step scaling rule and configure a set of step scaling policies that are triggered based on the condition of the event-triggered task. Step scaling rules are similar to simple scaling rules, except that each simple scaling rule defines only one scaling policy. You can use a step scaling rule to precisely control the number of ECS instances to be scaled in a scaling group.
Limits on using scaling rules:
  • You can create only a limited number of scaling rules for a scaling group. For more information, see Limits.
  • After a scaling rule is executed, the target number of ECS instances in the scaling group may fall outside of the specified range. In this case, Auto Scaling automatically adjusts the number of ECS instances to be added or removed to ensure that the number of ECS instances in the scaling group is within the specified range. Examples:
    • Assume that you have a scaling group named asg-bp19ik2u5w7esjcu****. The scaling group can have up to three instances. One of its scaling rules named add3 specifies that three instances will be added in a scaling activity. Currently, the scaling group has two instances. If the scaling rule add3 is executed, only one ECS instance is added to the scaling group.
    • Assume that you have a scaling group named asg-bp19ik2u5w7esjcu****. The scaling group must have at least two instances. One of its scaling rules named reduce2 specifies that two instances will be removed in a scaling activity. Currently, the scaling group has three instances. If the scaling rule reduce2 is executed, only one ECS instance is removed from the scaling group.
  • If you have overdue payments in your account, all scaling rules will fail to be executed.
    Notice Make sure that you have sufficient balance in your account to ensure the service availability of Auto Scaling.

Procedure

  1. Log on to the Auto Scaling console.
  2. Find the target scaling group and use one of the following methods to open the details page of the scaling group:
    • Click the ID of the scaling group in the Scaling Group Name/ID column.
    • Click Manage in the Actions column.
  3. In the left-side navigation pane, click Scaling Rules.
  4. Click Create Scaling Rule.
  5. In the Create Scaling Rule dialog box that appears, set required parameters and click Create Scaling Rule.

Simple scaling rule

The following table describes the parameters for configuring a simple scaling rule.
Parameter Description
Name The name of the scaling rule.
Rule Type The type of the scaling rule. Select Simple Scaling Rule for this parameter. Note that this parameter cannot be modified after the scaling rule is created.
Operation The operation to be executed when the scaling rule is triggered. The operations include:
  • Change to N instances: When the scaling rule is executed, the number of instances in the scaling group changes to N. A maximum of 500 instances can be added or removed at a time.
  • Add N instances: When the scaling rule is executed, N instances are added to the scaling group. A maximum of 500 instances can be added at a time.
  • Add instances by N%: When the scaling rule is executed, N% of the existing instances in the scaling group are added. A maximum of 500 instances can be added at a time.
  • Remove N instances: When the scaling rule is executed, N instances are removed from the scaling group. A maximum of 500 instances can be removed at a time.
  • Remove instances by N%: When the scaling rule is executed, N% of the existing instances in the scaling group are removed. A maximum of 500 instances can be removed at a time.
Cooldown Time (Seconds) Optional. The cooldown period. Unit: seconds. If this parameter is not specified, the cooldown period of the scaling group is used. For more information, see Cooldown time.

Target tracking scaling rule

The following table describes the parameters for configuring a target tracking scaling rule.
Parameter Description
Name The name of the scaling rule.
Rule Type The type of the scaling rule. Select Target Tracking Scaling Rule for this parameter. Note that this parameter cannot be modified after the scaling rule is created.
Reference Existing Predictive Scaling Rule Specifies whether to inherit the metric and target value from the predictive scaling rule of the scaling group if the predictive scaling rule exists.
Metric Name The name of a Cloud Monitor metric to be monitored. Valid values:
  • Average CPU Usage
  • Average Inbound Internal Traffic
  • Average Outbound Internal Traffic
  • Average Inbound Public Traffic
  • Average Outbound Public Traffic
Target Value The target value of the Cloud Monitor metric. The target tracking scaling rule keeps the Cloud Monitor metric close to the target value.
Warmup Time (Seconds) The instance warmup period. Unit: seconds. Auto Scaling adds instances in the warmup state to a scaling group, but does not report monitoring data to Cloud Monitor during the warmup period. When Auto Scaling calculates the number of instances to be scaled based on the Cloud Monitor metric, Auto Scaling does not count instances in the warmup state as existing instances in the scaling group. Otherwise, the metric value may change when the warmup period expires.
Disable Scale-in Specifies whether to disable scale-in events. This parameter affects the number of automatically created event-triggered tasks.
  • If this parameter is selected, only one event-triggered task for scale-out events is automatically created and associated with the target tracking scaling rule. The target tracking scaling rule then cannot remove ECS instances from the scaling group.
  • If this parameter is not selected, two event-triggered tasks are automatically created and associated with the target tracking scaling rule. One task is used for scale-out events, and the other task is used for scale-in events.
After a target tracking scaling rule is created, one or two event-triggered tasks are automatically created and associated with the rule. You can view the event-triggered tasks on the Event-Triggered Tasks page, as shown in the following figure.

Step scaling rule

The following table describes the parameters for configuring a step scaling rule.
Parameter Description
Name The name of the scaling rule.
Rule Type The type of the scaling rule. Select Step Scaling Rule for this parameter. Note that this parameter cannot be modified after the scaling rule is created.
Monitoring Type The monitoring type. Select the type of the monitoring event-triggered task to be associated with the scaling rule.
  • System Monitoring: Select this option to associate a system monitoring event-triggered task with the scaling rule.
  • Custom Monitoring: Select this option to associate a custom monitoring event-triggered task with the scaling rule.
Run At The event-triggered task to be associated with the scaling rule. The condition of the event-triggered task will be used as the reference for triggering step scaling operations.

For example, you can select an event-triggered task that generates an alert when the average CPU utilization is greater than or equal to 80% three times in a row.

If no event-triggered tasks are available, you can create one. For more information, see Create event-triggered tasks.
Note If an event-triggered task is created when you create a step scaling rule, the event-triggered task automatically uses the current step scaling rule as the triggered rule and the current scaling group as the monitored resource.
Operation The step scaling operations based on the condition of the event-triggered task. To set a step scaling operation, you must specify the size of the alert breach and the corresponding operation. When the event-triggered task generates an alert, Auto Scaling performs a step scaling operation based on the size of the alert breach. You must set at least one step scaling operation.
Examples:
  • Adds two ECS instances when the average CPU utilization is greater than or equal to 80% but less than 90%.
  • Adds three ECS instances when the average CPU utilization is greater than or equal to 90%.

The size of the alert breach for each step scaling operation must be set based on the condition of the event-triggered task. For example, if the condition is that the average CPU utilization is greater than or equal to 80% three times in a row, the lower limit of the alert breach for the initial step scaling operation must be greater than or equal to 80%.

Step scaling rules support the same operations as simple scaling rules, including changing to N instances, adding N instances, removing N instances, adding instances by N%, and removing instances by N%.

Warmup Time (Seconds) The instance warmup period. Unit: seconds. Auto Scaling adds instances in the warmup state to a scaling group, but does not report monitoring data to Cloud Monitor during the warmup period. When Auto Scaling calculates the number of instances to be scaled based on the Cloud Monitor metric, Auto Scaling does not count instances in the warmup state as existing instances in the scaling group. Otherwise, the metric value may change when the warmup period expires.

Assume that the instance warmup period is 300 seconds and two ECS instances are added to the scaling group. Within 300 seconds after the two ECS instances are calculated, Auto Scaling does not take the two instances into account when Auto Scaling calculates the average CPU utilization of ECS instances in the scaling group.

After you create a step scaling rule, you can view its associated event-triggered task on the Event-Triggered Tasks page, as shown in the following figure.