You need to enable JavaScript to run this app.
Load Balancer

Load Balancer

Copy page
Download PDF
Best Practices
Automatically adjusting the number of backend servers with the auto-scaling service
Copy page
Download PDF
Automatically adjusting the number of backend servers with the auto-scaling service
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​
  1. Log in to the CLB console.​
  1. Click Create Load Balancer. Configure the parameters of the CLB instance by referring to the table below.​
  • ​
    Parameter​
    Value​
    Basic information​
    ​
    Billing method​
    Pay-as-you-go​
    Regions​
    China (Beijing)​
    Name​
    clb-1​
    Network Configuration​
    ​
    IP version​
    IPv4​
    Network type​
    Internet​
    VPC​
    vpc-1​
    Subnet​
    subnet-1​
    IPv4 address​
    Automatic IP assignment​
    Associate an EIP​
    ​
    ISP​
    BGP (multi-line)​
    Metering method​
    Pay-by-bandwidth-cap​
    Bandwidth cap​
    20Mbps​
    ​
  1. Follow the console guidance to review and accept Legal.​
  1. Click Submit Order to navigate to the application submission success page.​
  1. Click Go to the console to navigate to the Instances page and view the newly created instance.​
Step 2: Create server group​
  1. On the instance list page, click the CLB instance name clb-1.​
  1. On the Server Group tab, click Add Server Group.​
  1. Input the name rsp-1.​
  1. Click Migrate to complete the action.​
Step 3: Add listener​
  1. On the details page of the CLB instance clb-1, select the Listener tab.​
  1. Click Add Listener and configure the protocol and listener parameters according to the table below.​
  • ​
    Parameter​
    Value​
    Listener name​
    listener-1​
    CLB protocol​
    HTTP​
    Listening port​
    80​
    Scheduling algorithm​
    Weighted Round Robin (WRR)​
    ​
  1. Keep the established timeout at the default value.​
  1. After completing the configuration, click Next.​
  1. On the Default Server Group configuration page, select the created backend server group rsp-1, then click Next.​
  1. On the Health Check configuration page, retain default values of all parameters and click Next.​
  1. On the Configuration Review page, click OK to complete the actions.​
Step Four: Create and configure a scaling group​
  1. Create a scaling group.​
  1. Log in to the Scaling Group Console.​
  1. Click the Create Scaling Group button and configure the related parameters as shown in the table below.​
  • ​
    Parameter​
    Value​
    Basic information​
    ​
    Regions​
    China (Beijing)​
    Scaling group name​
    as-1​
    Number of instances​
    ​
    Minimum number of instances​
    1​
    Maximum instances​
    3​
    Configuration information​
    ​
    VPC​
    vpc-1​
    Subnet​
    subnet-1​
    Associate CLB​
    Attach existing load balancer​
    Select load balancer​
    clb-1​
    tip​
    Select backend server group rsp-1, set the port to 80, and keep the weight at default.​
    ​
  1. Click OK to complete the operation.​
  1. Create a scaling configuration.​
  1. After successfully creating the scaling group, click Create scaling configuration source in the dialog box to enter the Scaling Configuration tab.​
  1. Click Create Scaling Configuration, see the table below and configure the related arguments.​
  • ​
    Parameter​
    Value​
    Basic configuration​
    ​
    Image​
    Custom image​
    tip​
    Select the image with your pre-configured service environment. For steps to create a custom image, refer to Creating a custom image.​
    Network and advanced configuration​
    ​
    Login password​
    password@123​
    Confirm password​
    password@123​
    Instance name​
    ecs-auto​
    Confirm configuration​
    ​
    Scaling configuration name​
    asconfig-1​
    Status after creation​
    Select to bind to the autoscaling group​
    ​
  1. Click Create Now to complete the actions.​
  1. Enable the scaling group.​
  1. Click Enable Scaling Group.​
  1. 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:​
  1. Click the name of the scaling group as-1.​
  1. On the Scaling Rule tab, click Create Scaling Rule, and configure the relevant parameters according to the table below.​
  • ​
    Parameter​
    Value (scale-out rule)​
    Value (scale-in rule)​
    Scaling rule name​
    asrule-1​
    asrule-2​
    Rule type​
    Alert task​
    Alarm task​
    Monitoring metrics​
    Maximum CPU usage > 80%​
    CPU usage max < 30%​
    Scaling action​
    Add instance, 1​
    reduce instances, 1​
    Status after creation​
    Enabled​
    Enabled​
    ​
  1. 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.​
​
Last updated: 2026.06.12 15:32:49