AS allows you to dynamically add or remove instances in a scaling group based on monitoring metrics, provided that you define the alarm trigger policy, including the status of the monitoring metrics that trigger the scaling, and how you want to scale in response to changing demand.
To create an alarm policy, you need to specify the conditions and actions:
We recommended you create two policies for each scaling group, one for scale-out and the other for scale-in. Once the traffic to your web application reaches the threshold of the alarm policy, AS executes the associated policy to scale your group in (by terminating instances) or out (by launching instances).
This is shown in the figure below:
For example, you have an e-commerce web application that currently runs on five instances. You plan to carry out an operational activity, and are concerned that the access traffic is much greater than you had expected. You can configure a scaling group to add two instances when the load on the current instance reaches 70%, and terminate extra instances when the load decreases to 40%.
Log in to Auto Scaling Console, and select Scaling group in the left sidebar.
Select the scaling group to modify, and click the ID of a scaling group to enter the Scaling Group Details page.
Select the Alarm Trigger Policy tab, and manage the alarm trigger policy associated with the scaling group on this page.
For the proper running of your existing business, if the CVMs in the cluster are used for the following purposes, you need to prevent them from being removed by the scale-in policy:
Multiple purposes: Apart from the tasks specified by the cluster, the CVM in the cluster is also used for other purposes, for example, the CVM is used as both a cache server and a file server.
Data storage: The CVM is stateful or stores data that other CVMs do not have. For example, the CVM stores the incremental data of other running CVMs in a cluster.
Image/Snapshot updates: The CVM is used to regularly update images and snapshots.
Step 1: In the Scaling group page, click the scaling group to which the CVM belongs to go to the management page.
Step 2: In the Instance List at the bottom of the management page, click Enable removal protection for the CVM.