The following diagram shows the Auto Scaling workflow.
After a scaling group, scaling configuration, scaling rule, and scaling trigger task are created, the system executes the following process (in this example, ECS instances are added):
The task triggers a scaling activity according to the trigger condition.
- The CloudMonitor task monitors the performance of ECS instances in the scaling group in real time and triggers the request for executing a scaling rule based on the configured alarm rules. For example, when the average CPU usage of all ECS instances in the scaling group exceeds 60%.
- The scheduled task triggers the request for executing a scaling rule at the specified time.
- The custom task triggers the request for executing a scaling rule based on the monitoring system and alarm rules. For example, the number of online users or the job queue.
- Health check tasks regularly check the health status of the scaling group and its ECS instances. If an ECS instance is found to be unhealthy (not in running status), the health check task triggers a request to remove the ECS instance from the group.
The system triggers a scaling activity through the ExecuteScalingRule interface and specifies the scaling rule to be executed by its unique Alibaba Cloud resource identifier (ARI) in this interface.
If a custom task needs to be executed, you must have the ExecuteScalingRule interface called in your program.
The system obtains information about the scaling rule, scaling group, and scaling configuration based on the scaling rule ARI entered in Step 2 and creates a scaling activity.
- The system uses the scaling rule ARI to query the scaling rule and scaling group, computes the number of ECS instances to be added, and configures the Server Load Balancer and RDS instances.
- According to the scaling group, the system queries the scaling configuration to determine the correct parameters (CPU, memory, bandwidth) to use when creating new ECS instances.
- The system creates scaling activity based on the number of ECS instances to be added, the ECS instance configuration, and the Server Load Balancer and RDS instance configurations.
During the scaling activity, the system creates ECS instances and configures Server Load Balancer and RDS instances.
- The system creates the specified number of ECS instances based on the instance configuration.
- The system adds the intranet IP addresses of the created ECS instances to the whitelist of the specified RDS instance and adds the created ECS instances to the specified Server Load Balancer instance.
After the scaling activity is completed, the system starts the cool-down function for the scaling group. The cool-down time must elapse before the scaling group can execute any new scaling activity.