This article explains how to automatically adjust the number of backend servers to ensure smooth operation of tidal traffic with irregular surges or declines while minimizing costs.
Scenarios
Tidal traffic with unpredictable surges or declines cannot accurately predict the exact timing of changes in traffic volume. If server quantity is not adjusted in time, it may affect service or cause resource waste.
By attaching the Server Group of the Classic Load Balancer (CLB) instance to the scaling group of the Auto Scaling (AS) service and configuring the corresponding scaling rule, the number of ECS instances in the scaling group can be automatically adjusted and added to the Server Group of the CLB instance, thereby achieving automatic scaling of the backend servers of the CLB instance, which helps improve the service capability of the CLB.
Prerequisites
Subnet-1 and vpc-1 have been created. For detailed steps, refer to Creating a VPC.
Configuration procedures
tip
The following section only covers essential parameters and their recommended values when configuring each service resource. For all parameters not explicitly discussed, retain the default settings unless otherwise required by your specific use case.
Step 1: Create a CLB instance
- Click Create Load Balancer. Configure the parameters of the CLB instance by referring to the table below.
- Follow the console guidance to review and accept Legal.
- Click Submit Order to navigate to the application submission success page.
- Click Go to the console to navigate to the Instances page and view the newly created instance.
Step 2: Create server group
- On the instance list page, click the CLB instance name clb-1.
- On the Server Group tab, click Add Server Group.
- Click Migrate to complete the action.
Step 3: Add listener
- On the details page of the CLB instance clb-1, select the Listener tab.
- Click Add Listener and configure the protocol and listener parameters according to the table below.
- Keep the established timeout at the default value.
- After completing the configuration, click Next.
- On the Default Server Group configuration page, select the created backend server group rsp-1, then click Next.
- On the Health Check configuration page, retain default values of all parameters and click Next.
- On the Configuration Review page, click OK to complete the actions.
Step Four: Create and configure a scaling group
- Click the Create Scaling Group button and configure the related parameters as shown in the table below.
- Click OK to complete the operation.
- Create a scaling configuration.
- After successfully creating the scaling group, click Create scaling configuration source in the dialog box to enter the Scaling Configuration tab.
- Click Create Scaling Configuration, see the table below and configure the related arguments.
- Click Create Now to complete the actions.
- Enable the scaling group.
- Click Enable Scaling Group.
- Click Migrate to complete the action.
At this point, the scaling group configuration is complete, and the state is Activated. The system will automatically create one ECS instance based on the scaling configuration and add it to backend server group rsp-1 in the CLB, meeting your daily operational needs.
Step five: create scaling rules
Configure the scaling rule by referring to the following steps in sequence:
- Click the name of the scaling group as-1.
- On the Scaling Rule tab, click Create Scaling Rule, and configure the relevant parameters according to the table below.
- Click Migrate to complete the action.
Result verification
- After enabling the scaling group, the system automatically creates one ECS instance and adds it to the backend server group rsp-1.
- At this time, the backend server group rsp-1 contains one ECS instance.
- When the maximum CPU usage of the backend servers exceeds 80%, the system automatically creates one ECS instance according to the scaling rule and adds it to the backend server group rsp-1.
- At this time, the backend server group rsp-1 contains two ECS instances.
- When the maximum CPU usage of the backend server is < 30%, the system automatically reduces one instance according to the scaling rules and removes it from the backend server group rsp-1.
- At this time, the backend server group rsp-1 contains one ECS instance.