This topic describes how to create a predictive scaling rule. 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 maximum and minimum numbers of Elastic Compute Service (ECS) instances for the scaling group.
When you create a scaling group, you can manually set the boundary values: minimum and maximum numbers of ECS instances for the scaling group. However, the boundary values you set may not reflect the actual requirements. If the minimum number of ECS instances exceeds the actual requirements, you may purchase excessive compute resources. If the maximum number of ECS instances cannot meet the actual requirements, the service stability may be affected due to insufficient compute resources.
After a predictive scaling rule is executed, the system can obtain historical monitoring data that is generated in a period of at least the past 24 hours. Based on the historical data, the system predicts the values of monitored metrics over the next 48 hours through machine learning. Then, the system can calculate the number of ECS instances that are required by the scaling group per hour and provide the number as the predicted value. Predictions are updated once a day, and 48 prediction tasks are created for each of the next 48 hours. Prediction tasks change the boundary values of the scaling group, but not the actual number of ECS instances in the scaling group.
A predictive scaling rule can be used together with a target tracking scaling rule or a simple scaling rule. When it is used with a target tracking scaling rule, we recommend that you set the same metric and target value for both rules. Otherwise, the number of instances in the scaling group may frequently change due to the difference in metrics.
- 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 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.
- In the left-side navigation pane, click Scaling Rules.
- Click Create Scaling Rule.
- Set parameters and click Create Scaling Rule.
A scaling group can have only one predictive scaling rule. The following table describes the parameters of a predictive scaling rule.
Parameter Description Name The name of the scaling rule. Rule Type The type of the scaling rule. Select Predictive Scaling Rule. Reference Existing Target Tracking Scaling Rule Specifies whether to use the predictive scaling rule with a target tracking scaling rule. If you select this option, Select Rule appears. Then, you can select a target tracking scaling rule. Select Rule The target tracking scaling rule for the predictive scaling rule to reference. This parameter appears when you select Reference Existing Target Tracking Scaling Rule. After you select a target tracking scaling rule, its Metric Name and Target Value apply to the predictive scaling rule. Metric Name The metric to be monitored by CloudMonitor. Valid values:
- Average CPU Usage (%)
- Average Inbound Internal Traffic (KB/Min)
- Average Outbound Internal Traffic (KB/Min)
Target Value The target value of the metric to be monitored by CloudMonitor. The predictive scaling rule calculates an appropriate predicted value based on multiple factors such as the target value.
If you change the target value, existing prediction tasks of the current scaling group will be cleared. New prediction tasks will be created within an hour.
Predicative Scaling Mode The prediction mode for the scaling group. Valid values:
- Forecast and Scale: produces predictions and creates prediction tasks.
- Forecast Only: produces predictions but does not create prediction tasks.
We recommend that you first select Forecast Only and change it to Forecast and Scale if you confirm that the predictions can meet your expectations. For more information about scaling rules, see Evaluate the prediction of a predictive scaling rule.
Preset Max Capacity The maximum number of ECS instances in the scaling group. This parameter is used together with Max Capacity Behavior.
The default value is the current maximum number of instances.
Max Capacity Behavior The action to be taken on the predicted value when it exceeds Preset Max Capacity. Valid values:
- Predicted Max Capacity Overwrites Preset Max Capacity: uses the predicted value as the maximum value for prediction tasks.
- Preset Max Capacity Overwrites Predicted Max Capacity: uses the preset maximum capacity as the maximum value for prediction tasks.
- Increase Predicted Max Capacity by Specified Ratio: increases the predicted value with a specified ratio before comparing it with the preset maximum capacity. When you select this option, the Increase Ratio field appears. This allows you to set the ratio.
Default value: Predicted Max Capacity Overwrites Preset Max Capacity.
Increase Ratio The ratio of the increment to the predicted value. This field appears when you set Max Capacity Behavior to Increase Predicted Max Capacity by Specified Ratio. The current predicted value increases with this ratio, and the predicted value after increase is used as the maximum value for prediction tasks. For example, if the current predicted value is 100 and increases with a ratio of 10%, the maximum value for prediction tasks is 110.
Valid values: 0 to 100. Default value: 0.
Scheduled Task Buffer Time (minutes) The buffer time before prediction tasks are executed. By default, all scheduled tasks that are automatically created for a predictive scaling rule are executed at the beginning of each hour. You can set a buffer time to execute prediction tasks ahead of schedule so that resources can be prepared in advance.
Valid values: 0 to 60. Default value: 0.