The purpose of a scaling rule varies based on its type. A scaling rule can be used to trigger a scaling activity or automatically 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. For information about the limits and purpose of each type of scaling rule, see Overview.
  • You can create only a limited number of scaling rules for a scaling group. To view the quota of scaling rules, go to 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 the region where Auto Scaling is activated.
  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 that appears, click the Scaling Rules and Event-triggered Tasks tab.
  6. Click the Scaling Rules tab and then click Create Scaling Rule in the upper-right corner.
  7. In the Create Scaling Rule dialog box, configure parameters of the scaling rule.
    1. Enter a rule name.
    2. Select a rule type and configure parameters as prompted.
      The following tables describe the parameters of each type of scaling rule.

      Parameters of simple scaling rules

      ParameterDescription
      OperationThe 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 configure the Minimum Number of Instances to Adjust parameter.
      Cooldown TimeOptional. The cooldown period of the scaling rule. Unit: seconds. If you do not configure the Cooldown Time parameter for the scaling rule, the cooldown period of the scaling group is used. For more information, see Cooldown time.

      Parameters of step scaling rules

      ParameterDescription
      Monitoring TypeThe type of 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 a system event-triggered task 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 a custom event-triggered task for the scaling rule.
      Start TimeThe 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 to the right of the Start Time text box. For information about the parameters of event-triggered tasks, see Manage event-triggered tasks.
      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.
      OperationThe step scaling operation and alert breach of 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%.

      You must configure the size of the alert breach for each step scaling operation based on the trigger condition 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 existing instances, and removing N% of the existing instances.

      Instance Warmup TimeThe 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 until 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

      ParameterDescription
      Metric TypeThe 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 ValueThe target value of the metric. Auto Scaling keeps the value of the monitored metric close to the target value.
      Instance Warmup TimeThe 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 until the warmup period ends.
      Threshold for Scale-out AlertsThe number of consecutive times that the event-triggered task created for scale-outs 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 AlertsThe number of consecutive times that the event-triggered task created for scale-ins 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-inSpecifies whether to disable scale-ins. This parameter affects the number of automatically created event-triggered tasks.
      • If you enable the Disable Scale-in feature, only one event-triggered task for scale-outs 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 enable the Disable Scale-in feature, two event-triggered tasks are automatically created and associated with the target tracking scaling rule. One task is used for scale-outs, and the other is used for scale-ins.

      Parameters of predictive scaling rules

      Note You can create only one predictive scaling rule for a scaling group.
      ParameterDescription
      Reference Existing Target Tracking Scaling RuleSpecifies 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 for the target tracking scaling rule.
      Select a ruleThis parameter is available only if you enable the Reference Existing Target Tracking Scaling Rule feature. You can select an existing target tracking scaling rule and use the values of the Metric Type and Target Value parameters of the target tracking scaling rule as the values of the Metric Type and Target Value parameters of the predictive scaling rule.
      Metric TypeThe type of the metric. Valid values:
      • (ECS) Average CPU Utilization. Unit: %.
      • (ECS) Average Inbound Internal Traffic. Unit: KB/min.
      • (ECS) Average Outbound Internal Traffic. Unit: KB/min.
      Target ValueThe 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 value of the Target Value parameter, Auto Scaling deletes the existing prediction task and creates a new prediction task within 1 hour.

      Predictive ModeThe 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 then change the value to Predict and Scale after you confirm that the predictions can meet your requirements. You can check whether the predictions meet your requirements on the details page of the predictive scaling rule. For more information, see View the prediction effect of a predictive scaling rule.

      Preset Max CapacityThe 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 MethodSpecifies 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 configure the Increase Ratio parameter.

      Default value: Predicted Capacity Overwrites Preset Max Capacity.

      Increase RatioThe ratio of the increase in 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 increases by this ratio is used the next time the prediction task runs. For example, if the predicted value is 100 and you set the Increase Ratio parameter 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 TimeThe 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 must manually execute simple scaling rules and step scaling rules. You can allow 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 period of the scaling rule and immediately execute the scaling rule. Within the specified cooldown period, 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 the region where Auto Scaling is activated.
  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 that appears, click the Scaling Rules and Event-triggered Tasks tab.
  6. On the Scaling Rules tab, find the scaling rule that you want to execute and click Execute in the Actions column.
  7. In the message that appears, click OK.

Automatically executes a scaling rule

Execution modeDescription
Executes a scaling rule by using a scheduled taskIf 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 taskIf your business load does not have obvious patterns, you can specify a scaling rule when you create an event-triggered task. Auto Scaling executes the scaling rule when the trigger conditions that are specified in the event-triggered task are met. For information about how to create event-triggered tasks, see Manage event-triggered tasks. For 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 scaling rule 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 the region where Auto Scaling is activated.
  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 that appears, click the Scaling Rules and Event-triggered Tasks tab.
  6. On the Scaling Rules tab, find the scaling rule that you want to modify or delete and click Edit or Delete in the Actions column.
    OptionOperation
    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 You cannot modify the setting of the Rule Type parameter for any type 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.