The function of a scaling rule depends on its type. A rule can trigger a scaling activity or set the boundary values for a scaling group. You can choose a scaling rule type based on your business needs. For example, if you only need to set the boundary values for your scaling group, you can use a predictive scaling rule. This topic describes how to create, execute, modify, and delete scaling rules.
Background information
Auto Scaling supports four types of scaling rules: simple scaling rules, step scaling rules, target tracking scaling rules, and predictive scaling rules. For more information, see Overview of scaling rules.
For scaling groups that contain ECS instances, you can create simple scaling rules, step scaling rules, target tracking scaling rules, and predictive scaling rules.
For scaling groups that contain ECI instances, you can create only simple scaling rules and target tracking scaling rules.
The number of scaling rules that you can create in a scaling group is limited. This quota depends on your usage of Auto Scaling. To view the quota, go to Quota Center.
Create a scaling rule
Log on to the Auto Scaling console.
In the left-side navigation pane, click Scaling Groups.
In the top navigation bar, select a region.
Find the scaling group that you want to manage and click View Details in the Actions column.
At the top of the page, click the Scaling Rules and Tasks tab.
On the Scaling Rules tab, click Create Scaling Rule.
Configure the parameters for the scaling rule.
Enter a Rule Name.
Select a Scaling Rule Type and configure the corresponding parameters.
The following tables describe the parameters for the four types of scaling rules.
Simple rules
You can configure these parameters for scaling groups that contain ECS and ECI instances.
Name
Description
Action to execute
Select an action as needed:
Adjust to N instances: After the scaling rule is executed, the number of instances in the scaling group changes to N. A maximum of 1,000 instances can be scaled.
Add N instances: After the scaling rule is executed, N instances are added to the scaling group. You can add a maximum of 1,000 instances.
Add N% of instances: After the scaling rule is executed, the number of instances in the scaling group increases by N%. A maximum of 1,000 instances can be scaled.
Remove N instances: After the scaling rule is executed, N instances are removed from the scaling group. You can remove a maximum of 1,000 instances.
Remove N% of instances: After the scaling rule is executed, the number of instances in the scaling group decreases by N%. A maximum of 1,000 instances can be scaled.
NoteIf you set Action to execute to Add N% of instances or Remove N% of instances, you must also set Minimum number of instances to adjust.
Cooldown time
This parameter is optional. Unit: seconds. If you do not specify this parameter, the cooldown time of the scaling group is used. For more information, see Cooldown time.
Step scaling rule
You can configure these parameters only for scaling groups that contain ECS instances.
Name
Description
Monitoring type
Select a monitoring type based on the event-triggered task that you want to associate.
System Monitoring: The monitoring metrics collected by CloudMonitor. If you select this option, you can specify a system monitoring task.
Custom Monitoring: The custom monitoring metrics that you report to CloudMonitor. If you select this option, you can specify a custom monitoring task.
Execution time
Specify an event-triggered task. The trigger conditions of the task are used as the reference for the step adjustments.
Example: The average CPU utilization is greater than or equal to 80% for three consecutive periods.
If no event-triggered tasks are available, you can create one. Click Create Event-triggered Task next to the Execution time parameter. For more information about the parameters, see Configure an event-triggered task.
NoteIf you create an event-triggered task when you create a step scaling rule, the Monitored Resource for the task is automatically set to the current scaling group, and the Alert Triggering Rule is automatically set to the current step scaling rule.
Action to execute
Configure step adjustments based on the trigger conditions of the event-triggered task. Specify the breach size and the corresponding action. After the task is triggered, Auto Scaling performs the corresponding action based on the breach size. You must configure at least one step adjustment.
Example:
If 80 <= Average CPU utilization < 90, add 2 instances.
If 90 <= Average CPU utilization < +∞, add 3 instances.
The breach size that you configure for each step adjustment is limited by the CloudMonitor metric. For example, if the CloudMonitor metric is "Average CPU utilization is greater than or equal to 80% for 3 consecutive periods", the step adjustments must start from >= 80%.
Step scaling rules support the same actions as simple scaling rules: Adjust to N instances, Add N instances, Remove N instances, Add N% of instances, and Remove N% of instances.
NoteIf you set Action to execute to Add N% of instances or Remove N% of instances, you must also set Minimum number of instances to adjust.
Ramp-up period
Unit: seconds. Instances in the ramp-up period are added to the scaling group but do not report monitoring data to CloudMonitor. When the number of instances to scale is dynamically calculated, instances in the ramp-up period are not counted as part of the current number of instances. This prevents metric fluctuations.
For example, if the ramp-up period for a step scaling rule is 300 seconds and two instances are added, the metric values of these two instances are not included in the calculation of the average CPU utilization of the scaling group for 300 seconds after the instances are created.
Target Tracking Rule
You can configure these parameters for scaling groups that contain ECS and ECI instances.
Name
Description
Metric type
Select a CloudMonitor metric based on the type of your scaling group.
If the scaling group contains ECS instances, you can select one of the following CloudMonitor metrics:
(ECS) Average CPU utilization. Unit: %.
(ECS) Average inbound internal traffic. Unit: kbit/min.
(ECS) Average outbound internal traffic. Unit: kbit/min.
(ECS) Average inbound Internet traffic. Unit: kbit/min.
(ECS) Average outbound Internet traffic. Unit: kbit/min.
(ALB) QPS per server in the server group. Unit: counts/s.
If the scaling group contains ECI instances, you can select one of the following CloudMonitor metrics:
CPU utilization. Unit: %.
Memory utilization. Unit: %.
(ALB) QPS per server in the server group. Unit: counts/s.
NoteIf you select the (ALB) QPS per server in the server group CloudMonitor metric, you must also select an ALB server group.
Target value
The target value for the selected CloudMonitor metric. The target tracking scaling rule keeps the metric value at or near the target value.
Ramp-up period
Unit: seconds. Instances within their ramp-up period are added to the scaling group but do not report monitoring data to CloudMonitor. When the number of instances to scale is dynamically calculated, these instances are not counted as part of the current number of instances. This prevents metric fluctuations.
Number of times the threshold must be met to trigger a scale-out alert
After you create a target tracking scaling rule, Auto Scaling automatically creates event-triggered tasks. This parameter specifies the number of consecutive times the threshold must be met to trigger the scale-out task.
Number of times the threshold must be met to trigger a scale-in alert
After you create a target tracking scaling rule, Auto Scaling automatically creates event-triggered tasks. This parameter specifies the number of consecutive times the threshold must be met to trigger the scale-in task.
Disable scale-in
How disabling scale-in affects the number of automatically created event-triggered tasks:
If you disable scale-in, the target tracking scaling rule creates only one event-triggered task for scale-out activities. This prevents ECS or ECI instances from being removed from the scaling group.
If you allow scale-in, the target tracking scaling rule creates two event-triggered tasks: one for scale-out activities and one for scale-in activities.
Predictive scaling rule
You can configure these parameters only for scaling groups that contain ECS instances. You can create only one predictive scaling rule for each scaling group.
Name
Description
Use an existing target tracking rule
This parameter is optional. It specifies whether to use an existing target tracking rule. If a target tracking rule already exists, you can use its Metric type and Target value.
Select rule
This parameter is optional. It appears only after you enable Use an existing target tracking rule. You can then select a target tracking rule to automatically use its Metric type and Target value.
Metric type
Select a CloudMonitor metric as needed:
(ECS) Average CPU utilization. Unit: %.
(ECS) Average inbound internal traffic. Unit: kbit/min.
(ECS) Average outbound internal traffic. Unit: kbit/min.
Target value
The target value for the selected CloudMonitor metric. The predictive scaling rule calculates a proper number of instances based on multiple factors, including the target value.
If you modify the target value, the scaling group deletes the existing prediction tasks and creates new ones within one hour.
Prediction mode
Select a prediction mode as needed:
Predict only: generates prediction results but does not create prediction tasks.
Predict and scale: generates prediction results and creates prediction tasks.
We recommend that you first select Predict only. If the prediction results meet your expectations, change the mode to Predict and scale. You can view the prediction results on the details page of the scaling rule. For more information, see View prediction results.
Preset maximum value
The maximum number of instances in the scaling group. This parameter is used with Handling method for maximum value.
The default value is the current maximum number of instances in the scaling group.
Handling method for maximum value
The method to process the predicted value when it is greater than the preset maximum value. You can select one of the following methods:
Predicted value overwrites preset maximum value: If the predicted value is greater than the preset maximum value, the maximum number of instances for the prediction task is the predicted value.
Preset maximum value overwrites predicted value: If the predicted value is greater than the preset maximum value, the maximum number of instances for the prediction task is the preset maximum value.
Add a specified percentage to the predicted value: This method is used with Increase percentage.
The default value is Predicted value overwrites preset maximum value.
Increase percentage
This parameter appears only if you set Handling method for maximum value to Add a specified percentage to the predicted value. The current predicted value is increased by this percentage to generate a new predicted value. For example, if the current predicted value is 100 and the increase percentage is 10%, the maximum number of instances for the prediction task is 110.
The default value of the increase percentage is 0%. The maximum value is 100%.
Pre-launch time
By default, prediction tasks that are automatically created by a predictive scaling rule are executed on the hour. You can set a pre-launch time to execute the prediction tasks in advance and prepare resources.
Unit: minutes. The default value is 0. The maximum value is 60.
Click OK.
After the scaling rule is created, you can find the scaling rule in the scaling rule list. Click the scaling rule ID to view details such as the scaling rule type, scaling rule identifier, execution time, and the action to be executed.
Execute a scaling rule
Precautions
You can execute a scaling rule to manually or automatically adjust ECS or ECI resources. You must execute simple and step scaling rules manually. In contrast, Auto Scaling automatically executes target tracking and predictive scaling rules.
Before you execute a scaling rule, note the following:
Your account must not have overdue payments. If your account has an overdue payment, scaling rule execution fails. To ensure that Auto Scaling works as expected, make sure that your account has a sufficient balance.
The scaling group to which the scaling rule belongs must be in the Enabled state.
If the expected number of instances feature is not enabled for the scaling group, no other scaling activities can be in progress. If the expected number of instances feature is enabled for the scaling group, no non-parallel scaling activities can be in progress. For more information, see Expected number of instances.
Procedure
The method for executing a scaling rule varies based on the business scenario. The following list describes the available methods.
Manual method: To temporarily adjust ECS or ECI resources, you can manually execute a scaling rule. If no scaling activities are in progress in the scaling group, a scaling activity triggered by a manually executed rule is immediately executed and does not have to wait for the cooldown time to elapse. During the cooldown time, the scaling group rejects only scaling activity requests that are triggered by CloudMonitor event-triggered tasks.
Automatic method: If your business has predictable traffic patterns, you can use a scheduled task to execute a scaling rule. If your business does not have predictable traffic patterns, you can use an event-triggered task that is based on monitoring metrics to execute a scaling rule.
Manual method
Log on to the Auto Scaling console.
In the left-side navigation pane, click Scaling Groups.
In the top navigation bar, select a region.
Find the scaling group that you want to manage and click View Details in the Actions column.
At the top of the page, click the Scaling Rules and Tasks tab.
On the Scaling Rules tab, find the scaling rule that you want to execute and click Execute in the Actions column.
Click OK.
Automatic method
Execution method | Description |
Execute a scaling rule using a scheduled task | When you create a scheduled task, specify a scaling rule. Auto Scaling executes the scaling rule at the specified time. For more information, see Configure a scheduled task. |
Execute a scaling rule using an event-triggered task | When you create an event-triggered task, specify a scaling rule. Auto Scaling executes the scaling rule when the alert conditions are met. For more information, see Configure an event-triggered task. Note For more information about event-triggered tasks, see Overview of event-triggered tasks. |
Modify or delete a scaling rule
If a scaling rule no longer meets your business requirements, you can modify its properties instead of re-creating it.
If you no longer need a scaling rule, you can delete it to free up your scaling rule quota.
Log on to the Auto Scaling console.
In the left-side navigation pane, click Scaling Groups.
In the top navigation bar, select a region.
Find the scaling group that you want to manage and click View Details in the Actions column.
At the top of the page, click the Scaling Rules and Tasks tab.
On the Scaling Rules tab, modify or delete a scaling rule.
Modify a scaling rule
Find the scaling rule that you want to modify and click Modify in the Actions column.
Modify the parameters as needed and click OK.
For information about the parameters, see Create a scaling rule.
NoteThe Scaling Rule Type cannot be modified for any scaling rule. For step scaling rules, the Execution time cannot be modified.
Delete a scaling rule
Find the scaling rule that you want to delete and click Delete in the Actions column.
In the dialog box that appears, click OK.