All Products
Search
Document Center

Auto Scaling:Reduce costs with Auto Scaling

Last Updated:Oct 09, 2026

In this tutorial, you use Auto Scaling to combine subscription, pay-as-you-go, and spot ECS instances so that your application can handle periodic business fluctuations at a lower cost.

Business scenario

An online education platform has peak class hours from 17:00 to 22:00 every day. Traffic is low at other times. To handle traffic during peak class hours, O&M engineers must retain compute resources for the peak period over the long term. These resources stay idle at other times, which wastes resources and increases costs. If traffic during the peak class period exceeds expectations, O&M engineers must also create ECS instances manually on a temporary basis.

If your application has the following characteristics, you can use a similar solution:

  • It is deployed as a cluster with more than one server.

  • It is highly fault tolerant and can accept the risk of interruption at any time. For example, a test workload that uses spot instances.

  • It has clear periodic peaks and troughs. For example, the service peak occurs from 17:00 to 22:00 each day, while resources are idle at other times.

Solution

Auto Scaling supports the combined use of pay-as-you-go instances and spot instances to meet traffic requirements during periodic business fluctuations at a lower cost.

You can use the following solution:

  • Outside peak and trough periods — (Recommended) Purchase subscription ECS instances for your workloads.

  • During peak and trough periods — Use scheduled tasks to add and release the required ECS instances, as described below:

  • During service peaks — The scaling group uses scheduled tasks to automatically add the required ECS instances temporarily. You can specify multiple instance types to combine pay-as-you-go instances and spot instances, which further reduces costs. The scaling group sorts instance types by vCPU unit price from low to high and preferentially selects instance types with a lower vCPU unit price.

  • During service troughs — The scaling group uses scheduled tasks to automatically release unnecessary ECS instances.

Business benefits

Using Auto Scaling to reduce costs provides the following benefits:

  • Zero standby instance cost — Auto Scaling supports the automatic creation and automatic release of ECS instances on demand, so no standby instances are required. You need to retain compute resources only for traffic outside peak and trough periods.

  • Zero O&M cost — You need to configure only the scale-out policy in advance. When the load increases, Auto Scaling automatically creates ECS instances and adds them to the whitelist of the RDS instance and the load balancing backend server group of the SLB instance. The entire process is triggered and completed automatically without manual intervention.

  • Outstanding cost performance — Auto Scaling supports the combined use of pay-as-you-go instances and spot instances. Spot instances can be purchased for as little as 10% of the ECS instance price. If the inventory of spot instances is insufficient, pay-as-you-go instances are delivered instead to ensure successful provisioning. The Cost Optimization Policy also supports spot instance compensation. Five minutes before an existing spot instance is released, Auto Scaling automatically attempts to create a new spot instance at the current lower price, providing outstanding cost performance.

Procedure

Evaluate your business modules based on your business architecture, and perform the following operations to reduce the costs of the required business modules:

Note

Before you start, create a custom image for the ECS instances of your application. For more information, see Create a custom image from an instance.

Step 1: Create subscription ECS instances from a custom image

Create the required number of subscription ECS instances to add to the scaling group and handle the workload of your business modules outside peak and trough periods.

  1. Log on to the ECS console.

  2. In the left-side navigation pane, choose Instances & Images > Image.

  3. In the upper-left corner of the page, select a region and resource group.

  4. Find the custom image for the instance. In the Actions area, click Create Instance.

  5. Configure the instance information and create the instance.

    • Set Billing Method to Subscription.

    • Region and Image are populated automatically.

    Configure other information as required. For more information, see Create with Custom Launch.

Step 2: Create and enable a scaling group

Create a scaling group for the business modules whose costs you want to reduce. In the scaling configuration, select the custom image of the application instance so that the automatically created ECS instances meet the application requirements.

  1. Log on to the Auto Scaling console.

  2. In the navigation pane on the left, click Scaling Groups.

  3. In the top navigation bar, select a region.

  4. Click Create Scaling Group, configure the parameters, and create a scaling group.

    • Set Scaling Group Name to a custom name, such as testname.

    • Set Instance Configuration Source to Create from Scratch.

    • Set Minimum Number of Instances to 0.

    • Set Maximum Number of Instances to 10.

    • The default value of Default cooldown (seconds) is 300.

    • Set Network Type to VPC.

    • Set Scaling Policy to Cost Optimization Policy.

      • Set Minimum Pay-as-you-go Instances to 0.

      • Set Percentage of Pay-as-you-go Instances to 30.

      • Set Lowest Cost Instance Types to 3.

    • Set Instance Reclaim Mode to Release.

    • Select the virtual private cloud that you created and the corresponding vSwitch.

    • Associate the RDS instances and the Classic Load Balancer (CLB, formerly SLB), Application Load Balancer (ALB), and Network Load Balancer (NLB) server groups that the current business module uses.

    Configure other information as required. For more information, see Create an ECS scaling group.

  5. Find the scaling group that you created and click View Details in the corresponding Actions column.

  6. On the left side of Basic Information tab, find Spot Instance Compensation Policy and complete operations below:

    • Set Enable Supplemental Spot Instances to enabled.

    • Set Use Pay-as-you-go Instances to Supplement Spot Capacity to enabled.

  7. In the navigation pane on the left, click Scaling Groups.

  8. Click Create Scaling Configuration and configure the parameters to create a scaling configuration.

    • Set Billing Method to Spot Instance.

    • Select three or more instance types for the instance configuration.

    • Set Select Image to your custom image.

    Configure other information as required. For more information, see Create a scaling configuration (ECS instance).

  9. Enable the scaling configuration and scaling group.

Step 3: Add subscription ECS instances and configure automatic scaling policies

Add subscription ECS instances to the scaling group and create scheduled tasks to scale smoothly according to business peaks and troughs. This approach maximizes cost reductions by using spot instances.

  1. Go to the Instance Management tab and add the subscription ECS instances that you created to the scaling group.

  2. Set the subscription ECS instances to the protection status so that your business runs normally outside peak and trough periods.

  3. Go to the Scaling Groups page and modify the minimum and maximum numbers of instances in the scaling group based on your business requirements.

    For more information about modifying the maximum and minimum numbers of instances in a scaling group, see Configure scaling groups.

  4. On the scaling group details page, select Scaling Rules and Tasks > Scaling Rules, and create two simple scaling rules.

    The main parameters to configure are as follows:

    • For each scaling rule, set Rule Type to Simple Scaling Rule.

    • Configure the following rules for Operation:

      Configure other information as required. For more information, see Configure scaling rules.

      • Simple scaling rule 1: When the scaling group needs a scale-out, add 5 instances.

      • Simple scaling rule 2: When the scaling group needs a scale-in, remove 5 instances.

  5. On the scaling group details page, select Scaling Rules and Tasks > Scheduled Tasks and create two scheduled tasks.

    • Configure the following rules for Executed At:

      • Scheduled Task 1: When a scale-out is required before the service peak, such as 17:00, set the execution time to November 20, 2021, 16:59.

      • Scheduled Task 2: When a scale-in is required before the service trough, such as 22:00, set the execution time to November 20, 2021, 21:59.

    • Set Scaling Group to the scaling group to which the subscription ECS instances were added.

    • Set Recurrence according to the business requirements.

    • Set Scaling Method to Select Existing Scaling Rule.

    • Configure the following rules for Simple Scaling Rule:

      • Scheduled Task 1: To scale out before the service peak at 17:00, select Simple scaling rule 1.

      • Scheduled Task 2: To scale in before the service trough at 22:00, select Simple scaling rule 2.

    Configure other information as required. For more information, see Configure scheduled tasks.

Result

On the Scaling Activities page, you can view the scaling activity details to check whether the instances in the scaling group perform scale-out and scale-in operations normally. For more information, see Scaling activity details.

  • The subscription ECS instances are set to the protection status to handle workloads outside peak and trough periods. ECS instances in the protection status are not removed from the scaling group, and the weight of SLB backend server is not affected.

  • During service peaks, the scaling group uses scheduled tasks for the automatic creation of the required number of ECS instances more smoothly. Because the Cost Optimization Policy is used and spot instance compensation is enabled, ECS instances are purchased at a lower price with better cost performance.

  • During service troughs, the scaling group uses scheduled tasks for the automatic release of unnecessary ECS instances.