All Products
Search
Document Center

Auto Scaling:Save your money with Auto Scaling

Last Updated:Jul 19, 2024

This topic describes how to enable Auto Scaling to purchase a combination of pay-as-you-go Elastic Compute Service (ECS) instances and preemptible instances to effectively handle anticipated traffic variations and optimize cost savings.

Business scenarios

An online education platform encounters heightened traffic between 17:00 and 22:00 daily, whereas traffic significantly diminishes outside these peak hours. O&M engineers must constantly provision sufficient computing resources to guarantee service availability during peak hours, resulting in idle capacity and inefficient cost management during off-peak hours. Additionally, unexpected traffic surges require immediate manual provisioning of ECS instances by O&M engineers, further complicating operations.

You can use the solution provided in this topic if your application has the following characteristics:

  • Your application is deployed in a cluster, and the cluster has more than one server.

  • The application is highly fault-tolerant and can still run in the event of a failure. Example: the test service that is deployed on a preemptible instance.

  • The application has predictable traffic variations. For example, the application may encounter consistent traffic peaks between 17:00 and 22:00 daily, with significantly reduced computing resource usage during all other times.

Solutions

Auto Scaling combines pay-as-you-go and preemptible instances to efficiently manage anticipated traffic variations and minimize costs.

You can use the following solutions:

  • To accommodate steady traffic demands, you can purchase subscription ECS instances.

  • To optimize resource allocation, you can create scheduled tasks that automatically add ECS instances during peak hours and remove them during off-peak hours. A scheduled task can provide the following features:

    • To optimally handle peak-hour traffic demands while keeping costs low, the scheduled task prompts Auto Scaling to provision a combination of pay-as-you-go ECS instances and preemptible instances during peak hours. In order to maximize cost savings, Auto Scaling favorably provisions instances of the instance types which leverage the lowest-priced vCPU resources.

    • During off-peak hours, the scheduled task prompts Auto Scaling to release idle ECS instances.

Benefits

Auto Scaling offering the following benefits, which enable you to effectively minimize expenses:

  • Zero upfront resource setup costs

    Auto Scaling creates and releases ECS instances based on your business requirements, eliminating the requirement for any upfront costs related to resource setup. You need to only focus on reserving computing resources specifically for those predictable loads.

  • Zero O&M costs

    To prepare for peak hours, you can create scaling policies in advance. As traffic surges, Auto Scaling automatically provisions ECS instances and adds them to the backend server group of the attached Server Load Balancer (SLB) instance. Auto Scaling also updates the IP address whitelist of the attached ApsaraDB RDS instance by adding the private IP addresses of the new instances to ensure seamless connectivity. The entire sequence, from triggering to completion, is automated and occurs without any manual intervention.

  • Ultra-high cost performance

    Auto Scaling supports any combination of pay-as-you-go and preemptible instances. Preemptible instances can potentially reduce your costs by up to 90%. In scenarios where preemptible instances prove inadequate, pay-as-you-go instances are automatically provisioned to guarantee uninterrupted service. To further enhance cost efficiency, Auto Scaling also provides the Enable Supplemental Preemptible Instances feature when the cost optimization policy is specified. Enabling this feature triggers Auto Scaling to provision additional preemptible instances at reduced rates, five minutes prior to the termination of current preemptible instances.

Procedure

To minimize costs for vital business components, conduct an evaluation grounded in your business infrastructure and then perform the following operations:

Note

Before you proceed, you must create a custom image based on the ECS instance currently hosting your application. For information about how to create a custom image, see Create a custom image from an instance.

Step 1: Use a custom image to create subscription ECS instances

This step describes how to provision a defined number of subscription ECS instances based on a custom image. Auto Scaling adds these instances to a scaling group to accommodate steady traffic demands of specified business modules.

  1. Log on to the ECS console.

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

  3. In the top navigation bar, select the region and resource group to which the resource belongs. 地域

  4. Find the desired custom image and click Create Instance in the Actions column.

  5. Configure parameters based on your business requirements to complete instance creation.

    • Set Billing Type to Subscription.

    • Region and Image are auto-filled.

    For information about other parameters, see Create an instance on the Custom Launch tab.

Step 2: Create and enable a scaling group

This step describes how to create a scaling group tailored for business modules with budget constraints and incorporate a custom image in a scaling configuration to guarantee that any automatically provisioned ECS instances conform precisely to your application requirements.

  1. Log on to the Auto Scaling console.

  2. In the left-side navigation pane, click Scaling Groups.

  3. In the top navigation bar, select the region where Auto Scaling is activated.

  4. Click Create and configure parameters based on your business requirements to complete group creation.

    • Enter a custom name such as testname in the Scaling Group Name text box.

    • Set Instance Configuration Source to Create from Scratch.

    • Set Minimum Number of Instances to 0.

    • Set Maximum Number of Instances to 10.

    • Set Default Cooldown Time (Seconds) to 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.

      • Turn on Enable Supplemental Preemptible Instances.

      • Turn on Use Pay-as-you-go Instances to Supplement Preemptible Capacity. By default, this feature is enabled.

    • Set Instance Reclaim Mode to Release.

    • Select a virtual private cloud (VPC) and one or more vSwitches that you created.

    • Configure Associate CLB Instance, Associate ALB and NLB Server Groups, and Associate ApsaraDB RDS Instance based on the requirements of your business modules.

    Configure other parameters based on your business requirements. For more information, see Manage scaling groups.

  5. Find the scaling group and click Details in the Actions column.

  6. In the upper part of the scaling group details page, click the Instance Configuration Sources tab.

  7. Click Create Scaling Configuration and configure parameters based on your business requirements to complete scaling configuration creation.

    • Set Billing Method to Preemptible Instance.

    • Select three or more instance types from the Select Instance Type drop-down list.

    • Select your custom image from the Select Image drop-down list.

    Configure other parameters based on your business requirements. For more information, see Create a scaling configuration of the ECS type.

  8. Enable the scaling configuration and the scaling group.

Step 3: Add subscription ECS instances and configure a scaling policy

This step describes how to add subscription ECS instances to the scaling group and how to create a scheduled task to implement seamless scaling during peak hours. This step also shows that preemptible instances can maximize your cost savings.

  1. On the Instances tab, add the created ECS instances to the scaling group.

  2. Put the subscription ECS instances into the Protected state to ensure service availability when the traffic is stable.

  3. On the Basic Information tab, change the minimum and maximum numbers of instances in the scaling group based on your business requirements.

    For more information about how to change the maximum and minimum numbers of instances in a scaling group, see Modify scaling groups.

  4. On the details page of the scaling group, choose Scaling Rules and Event-triggered Tasks > Scaling Rules to create two simple scaling rules.

    You must configure the following parameters:

    • Set Rule Type to Simple Scaling Rule.

    • Set Operation based on the following rules:

      • Simple Scaling Rule 1: When a scale-out event is triggered, five ECS instances are added to the scaling group.

      • Simple Scaling Rule 2: When a scale-in event is triggered, five ECS instances are removed from the scaling group.

    Configure other parameters based on your business requirements. For more information, see Manage scaling rules.

  5. On the details page of the scaling group, choose Scaling Rules and Event-triggered Tasks > Scheduled Tasks to create two scheduled tasks.

    • Set Executed At based on the following rules:

      • Scheduled Task 1: Set the value to Nov. 20, 2021, 4:59 PM to immediately trigger a scale-out event when the peak hours arrive.

      • Scheduled Task 2: Set the value to Nov. 20, 2021, 9:59 PM to immediately trigger a scale-in event when the off-peak hours arrive.

    • By default, the scaling group in which the subscription ECS instances are provisioned is selected.

    • Set Scaling Method to Select Existing Scaling Rule.

    • Set Simple Scaling Rule based on the following rules:

      • Scheduled Task 1: Select Simple Scaling Rule 1 to immediately trigger a scale-out event when the peak hours arrive.

      • Scheduled Task 2: Select Simple Scaling Rule 2 to immediately trigger a scale-in event when the off-peak hours arrive.

    Configure other parameters based on your business requirements. For more information, see Create scheduled tasks.

Verify the result

You can go to the Scaling Activities tab to view the scaling activity details. Based on the scaling activity details, you can verify whether the defined number of ECS instances are scaled as expected. For more information, see View the details of a scaling activity.

  • Subscription ECS instances are put into the Protected status, which ensures they are securely reserved and optimized to handle predictable, consistent traffic loads. ECS instances in the Protected state stay intact within the scaling group, avoiding unintended deletion. Their backend server roles for the attached SLB instance and their respective weights in load distribution remain unaffected.

  • Auto Scaling proactively increases the number of ECS instances based on your prearranged schedules, which ensures adequate capacity to handle increased traffic demands during peak hours. After you configure the cost optimization policy and enable the Enable Supplemental Preemptible Instances feature, you can purchase ECS instances at lower costs.

  • Auto Scaling scales in ECS instances during off-peak hours based on the scheduled tasks that you created.