The purpose of a scaling rule varies based on its type. A scaling rule can be used to trigger a scaling activity or set the minimum and maximum numbers of instances for a scaling group. This topic describes how to create, execute, modify, and delete scaling rules.

Background information

  • You can create four types of scaling rules in Auto Scaling.
  • You can create only a limited number of scaling rules for a scaling group. To view the quota of scaling rules that you can create, visit Quota Center.
  • You can create simple scaling rules, step scaling rules, target tracking scaling rules, and predictive scaling rules for scaling groups that contain Elastic Compute Service (ECS) instances. You can create only simple scaling rules and target tracking scaling rules for scaling groups that contain elastic container instances.

Create a scaling rule

  1. Log on to the Auto Scaling console.
  2. In the left-side navigation pane, click Scaling Groups.
  3. In the top navigation bar, select a region.
  4. Find the scaling group for which you want to create a scaling rule and click Details in the Actions column.
  5. In the upper part of the page, click the Scaling Rules and Activities tab, and then click the Scaling Rules tab.
  6. Click Create Scaling Rule.
  7. In the Create Scaling Rule dialog box, configure parameters for the scaling rule.
    1. Enter a rule name.
    2. Select the rule type and configure parameters as prompted.
      The following tables describe the parameters of each type of scaling rule.

      Parameters of simple scaling rules

      Parameter Description
      Operation The operation that is performed when the scaling rule is executed. Valid values:
      • Change to N Instances: When the scaling rule is executed, the number of instances in the scaling group is changed to N. Up to 500 instances can be added to or removed from a scaling group.
      • Add N Instances: When the scaling rule is executed, N instances are added to the scaling group. Up to 500 instances can be added to a scaling group.
      • Add N%: When the scaling rule is executed, N% of the existing instances in the scaling group are added. Up to 500 instances can be added to a scaling group.
      • Remove N Instances: When the scaling rule is executed, N instances are removed from the scaling group. Up to 500 instances can be removed from a scaling group.
      • Remove N%: When the scaling rule is executed, N% of the existing instances in the scaling group are removed. Up to 500 instances can be removed from a scaling group.
        Note If you set the Operation parameter to Add N% or Remove N%, you must also configure the Minimum Number of Instances to Adjust parameter.
      Cooldown Time The cooldown period. Unit: seconds. This parameter is optional. If you do not configure the Cooldown Time parameter of the scaling rule, the cooldown time of the scaling group is used. For more information, see Cooldown time.

      Parameters of step scaling rules

      Parameter Description
      Monitor Type The type of the metric that you want to monitor. Valid values:
      • System Monitoring: the system metrics that are provided by CloudMonitor. If you set the Monitoring Type parameter to System Monitoring, you can specify an event-triggered task that is created by the system for the scaling rule.
      • Custom Monitoring: the custom metrics that are reported to CloudMonitor. If you set the Monitoring Type parameter to Custom Monitoring, you can specify an event-triggered task that you created for the scaling rule.
      Start Time The point in time at which the scaling rule is executed by an event-triggered task. The conditions to trigger the event-triggered tasks are used as the reference for step scaling.

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

      If no event-triggered task is available, you can create an event-triggered task for the step scaling rule. To create an event-triggered task for a step scaling rule, click Create Event-triggered Task next to the Start Time field.
      Note If you create an event-triggered task when you create a step scaling rule, the resource that is monitored by the event-triggered task is the scaling group for which you create the step scaling rule, and the trigger rule of the event-triggered task is the step scaling rule that you create.
      Operation The step scaling operation and alert breach based on the conditions to trigger the event-triggered task that is associated with the step scaling rule. After the event-triggered task is triggered, Auto Scaling performs the specified operation to scale instances in steps. You must specify 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 configured based on the trigger conditions of the event-triggered task. For example, the event-triggered task is triggered when the average CPU utilization is greater than or equal to 80% for three consecutive times. In this case, 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 N% of the instances, and removing N% of the instances.

      Instance Warmup Time The period of time during which instances are in the warmup state. Unit: seconds. Auto Scaling adds instances in the warmup state to a scaling group but does not report the monitoring data of the instances to CloudMonitor. When Auto Scaling calculates the number of instances to scale based on the monitoring data, Auto Scaling does not count instances in the warmup state as part of the existing instances in the scaling group to prevent metric values from fluctuating when the warmup period ends.

      For example, you set the Instance Warmup Time parameter of a step scaling rule to 300 seconds. After Auto Scaling executes the step scaling rule to create two instances, the average CPU utilization of the two instances is not counted when Auto Scaling calculates the average CPU utilization of instances in the scaling group within 300 seconds.

      Parameters of target tracking scaling rules

      Parameter Description
      Metric Type The type of the metric. Valid values:
      • (ECS) Average CPU Utilization
      • (ECS) Average Inbound Internal Traffic
      • (ECS) Average Outbound Internal Traffic
      • (ECS) Average Inbound Public Traffic
      • (ECS) Average Outbound Public Traffic
      Target Value The target value of the metric. Auto Scaling maintains the value of the monitored metric close to the target value.
      Instance Warmup Time The period of time during which instances are in the warmup state. Unit: seconds. Auto Scaling adds instances in the warmup state to a scaling group but does not report the monitoring data of the instances to CloudMonitor. When Auto Scaling calculates the number of instances to scale based on the monitoring data, Auto Scaling does not count instances in the warmup state as part of the existing instances in the scaling group to prevent metric values from fluctuating when the warmup period ends.
      Threshold for Scale-out Alerts 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 associated with the target tracking scaling rule.
      Threshold for Scale-in Alerts 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 associated with the target tracking scaling rule.
      Disable Scale-in Specifies whether to disable scale-in activities. This parameter affects the number of automatically created event-triggered tasks.
      • If you select this parameter, only one event-triggered task for scale-out activities is automatically created and associated with the target tracking scaling rule. In this case, no instances are removed from the scaling group.
      • If you do not select this parameter, two event-triggered tasks are automatically created and associated with the target tracking scaling rule. One task is used for scale-out activities, and the other task is used for scale-in activities.

      Parameters of predictive scaling rules

      Note You can create only one predictive scaling rule for a scaling group.
      Parameter Description
      Reference Existing Target Tracking Scaling Rule Specifies whether to reference an existing target tracking scaling rule. If a target tracking scaling rule exists in the scaling group, you can use the values of the Metric Type and Target Value parameters that are specified in the target tracking scaling rule.
      Select Rule This parameter is available only if you select the Reference Existing Target Tracking Scaling Rule parameter. You can select an existing target tracking scaling rule and use the values of the Metric Type and Target Value parameters as the values of the Metric Type and Target Value parameters of the predictive scaling rule.
      Metric Type The type of the metric. Valid values:
      • (ECS) Average CPU Utilization. Unit: %.
      • (ECS) Average Inbound Internal Traffic. Unit: KB/min.
      • (ECS) Average Inbound Internal Traffic. Unit: KB/min.
      Target Value The target value of the metric. When the predictive scaling rule is executed, Auto Scaling calculates the appropriate number of instances that can be scaled based on factors such as the target value.

      If you modify the setting of the Target Value parameter, Auto Scaling deletes the existing prediction task and creates a new prediction task within 1 hour.

      Predicative Mode The mode in which the predictive scaling rule works. Valid values:
      • Predict Only: produces predictions but does not create a prediction task.
      • Predict and Scale: produces predictions and creates a prediction task.

      We recommend that you select Predict Only and change it to Predict and Scale after you confirm that the predictions can meet your requirements. On the details page of the predictive scaling rule, you can check whether the predictions meet your requirements. For more information, see View the prediction effect of a predictive scaling rule.

      Preset Max Capacity The upper limit of the instances in the scaling group. This parameter is used together with the Maximum Capacity Handling Method parameter.

      If you do not configure this parameter, the current maximum number of instances in the scaling group is used.

      Maximum Capacity Handling Method Specifies whether to use the predicted value or the preset maximum capacity if the predicted value is greater than the preset maximum capacity. Valid values:
      • Predicted Capacity Overwrites Preset Max Capacity: uses the predicted value if the predicted value is greater than the preset maximum capacity.
      • Preset Max Capacity Overwrites Predicted Capacity: uses the preset maximum capacity if the predicted value is greater than the preset maximum capacity.
      • Predicted Capacity with Additional Ratio: uses the predicted value that is increased by a specific ratio. If you select this value, you must also configure the Increase Ratio parameter.

      Default value: Predicted Capacity Overwrites Preset Max Capacity.

      Increase Ratio The ratio of the increase of the predicted value. This parameter is available only if you set the Maximum Capacity Handling Method parameter to Predicted Capacity with Additional Ratio. The predicted value that increased by this ratio is used the next time the prediction task runs. For example, if the predicted value is 100 and the Increase Ratio parameter is set to 10%, the predicted value that is used the next time the prediction task runs is 110.

      Valid values: 0 to 100. Default value: 0.

      Pre-launch Time The period of time at which the prediction task that is created by the predictive scaling rule is pre-launched. By default, the prediction task is executed on the hour. You can configure the Pre-launch Time parameter to run the prediction task and prepare resources in advance.

      Unit: seconds. Default value: 0. Maximum value: 60.

  8. Click OK.
    After you create a scaling rule, the scaling rule appears on the Scaling Rules tab. You can click the ID of the scaling rule to view information such as the rule type, unique identifier, execution time, and scaling operation of the scaling rule.

Execute a scaling rule

You can execute a scaling rule to manually or automatically scale ECS instances or elastic container instances. You must manually execute simple scaling rules and step scaling rules. You can configure Auto Scaling to execute target tracking scaling rules and predictive scaling rules. Before you execute a scaling rule, make sure that the following requirements are met:

  • You have no overdue payments within your Alibaba Cloud account. If you have overdue payments, all scaling activities fail. If you want Auto Scaling to provide services as expected, make sure that you have sufficient balance within your Alibaba Cloud account.
  • The scaling group to which the scaling rule that you want to execute belongs must be in the Enabled state.
  • If you do not specify an expected number of instances for the scaling group to which the scaling rule that you want to execute belongs, no scaling activities can be executed in the scaling group. If you specify an expected number of instances for the scaling group to which the scaling rule that you want to execute belongs, no non-parallel scaling activities can be executed in the scaling group. For more information, see Expected number of instances.

Manually execute a scaling rule

If you temporarily need ECS instances or elastic container instances, you can manually execute a scaling rule. If no scaling activities are in progress in the scaling group, you can ignore the specified cooldown time and immediately execute the scaling rule. Within the specified cooldown time, Auto Scaling rejects scaling requests initiated by event-triggered tasks that are monitored by CloudMonitor.

  1. Log on to the Auto Scaling console.
  2. In the left-side navigation pane, click Scaling Groups.
  3. In the top navigation bar, select a region.
  4. Find the scaling group for which you want to execute a scaling rule and click Details in the Actions column.
  5. In the upper part of the page, click the Scaling Rules and Activities tab, and then click the Scaling Rules tab.
  6. Find the scaling rule that you want to execute and click Execute in the Actions column.
  7. Click OK.

Automatically executes a scaling rule

Execution mode Description
Executes a scaling rule by using a scheduled task If your business load has obvious patterns, you can specify a scaling rule when you create a scheduled task. This way, Auto Scaling executes the scaling rule based on the point in time that is specified in the scheduled task. For information about how to create scheduled tasks, see Create a scheduled task.
Executes a scaling rule by using an event-triggered task If your business load does not have obvious patterns, you can specify a scaling rule when you create an event-triggered task. This way, Auto Scaling executes the scaling rule when the trigger conditions that are specified in the event-triggered task are met. For more information about event-triggered tasks, see Overview.

Modify or delete a scaling rule

  • If your scaling rule no longer meets your business requirements, you can modify the parameter settings of the scaling rule. You do not need to create a new scaling rule.
  • If you no longer need a scaling rule, you can delete the scaling rule to free up the quota.
  1. Log on to the Auto Scaling console.
  2. In the left-side navigation pane, click Scaling Groups.
  3. In the top navigation bar, select a region.
  4. Find the scaling group whose scaling rule you want to modify or delete and click Details in the Actions column.
  5. In the upper part of the page, click the Scaling Rules and Activities tab, and then click the Scaling Rules tab.
  6. Modify or delete a scaling rule.
    Action Procedure
    Modify a scaling rule
    1. Find the scaling rule that you want to modify and click Edit in the Actions column.
    2. In the Edit Scaling Rule dialog box, modify parameter settings based on your business requirements and click OK.

      For information about the parameters, see Create a scaling rule.

      Note For all types of scaling rules, you cannot modify the setting of the Rule Type parameter for all types of scaling rules. You cannot modify the setting of the Start Time parameter for step scaling rules.
    Delete a scaling rule
    1. Find the scaling rule that you want to delete and click Delete in the Actions column.
    2. In the Delete Scaling Rule message, click OK.