All Products
Search
Document Center

Auto Scaling:Reduce scaling group costs with spot instances

Last Updated:Jun 20, 2026

After you create a scaling group, you can set appropriate scaling policies to improve resource utilization and reduce costs. To further lower your costs, you can add spot instances to use ECS instances at a lower price. This topic shows you how to use spot instances to reduce your cluster costs.

Important

Only scaling groups for ECS instances support spot instances.

What is a spot instance?

A spot instance is a type of on-demand instance that offers the same performance as a regular ECS instance. Its price changes in real time based on market supply and demand, saving you up to 90% compared to a pay-as-you-go instance. Spot instances have the following characteristics:

  • Identical performance: For the same instance type, a spot instance performs identically to a pay-as-you-go instance. Only the billing method is different.

  • Bidding mechanism: You can set a bid price when you create a spot instance. Alibaba Cloud adjusts the market price based on current supply and demand. If the market price exceeds your bid, the instance is reclaimed. You can also use Automatic Bidding, which automatically follows the market price up to the price of a pay-as-you-go instance.

  • Price matching mechanism: The price of an instance changes in real time based on market supply and demand. Your bid is compared with the market price. If your bid is higher than the market price and inventory is sufficient, a spot instance is created.

  • Interruption and reclamation mechanism: Spot instances are subject to an interruption and reclamation mechanism. If the market price exceeds your bid or if inventory is insufficient, the instance is interrupted and reclaimed.

  • Protection period: You can set a 1-hour protection period to prevent the instance from being reclaimed within the first hour after its creation.

For more information about spot instances, see What is a spot instance?.

Summary: When using a scaling group, you can use lower-priced spot instances to reduce costs. However, this comes at the cost of stability, as there is no guarantee that instances will be successfully created or will run indefinitely.

Balance cost and stability with spot instances

Using lower-priced spot instances can effectively reduce the cost of your instance cluster in a scaling group. However, due to their inherent instability, you need to carefully assess the potential impact on your cluster's overall stability. A scaling group's stability has two key aspects:

  • Scale-out stability: The ability to launch new instances in a timely and reliable manner to meet scaling demands when the workload increases.

    When you use spot instances, their creation might fail due to market price fluctuations or insufficient inventory. This can affect scale-out stability, but you can configure several mechanisms to improve it.

  • Instance stability: The ability to ensure that running instances operate continuously without unexpected interruptions.

    Introducing spot instances means some instances might be automatically reclaimed due to market price fluctuations or insufficient inventory. This requires your application to recover quickly and seamlessly switch to other available resources after an instance is interrupted.

Finding the right balance between cost savings and cluster stability is crucial for maintaining service reliability and performance.

Balancing cost and stability

Use the following strategies to balance cost and cluster stability.

  • Set a reasonable bidding strategy: By setting a bid slightly higher than the market price but lower than the pay-as-you-go price, you can increase your chances of acquiring spot instances while reducing the management overhead caused by frequent interruptions.

  • Use a mix of instance types: When adding spot instances to a scaling group, you must adjust the ratio of spot instances to pay-as-you-go instances based on your business needs to balance cost and cluster stability.

    For example, you can set the proportion of pay-as-you-go instances to the minimum capacity required to ensure stable operation and use spot instances for the elastic portion to reduce costs.

    The following figure shows how cluster stability and cost change with different instance ratios. As the proportion of spot instances in the cluster increases, costs decrease, but stability also decreases.

    使用抢占式实例降低成本

Improve cluster stability

In addition to designing a balanced strategy, you can use the following configurations to further enhance cluster stability.

  • Combine instance types to improve scale-out success

    Configuring multiple instance types lets a scaling group draw from their combined inventory, increasing the availability of spot instances and improving the scale-out success rate.

  • Combine zones to improve scale-out success

    Configuring vSwitches in multiple zones enables the scaling group to create spot instances across those zones. This expands the available spot instance inventory and improves the scale-out success rate.

  • Supplement spot capacity to maintain stability

    By using the Use Pay-as-you-go Instances to Supplement Spot Capacity feature, the system automatically creates pay-as-you-go instances when spot instance inventory is insufficient. This prevents performance gaps caused by failed spot instance creation.

  • Replace pay-as-you-go with spot instances

    Enabling the Replace Pay-as-you-go Instance with Spot Instance feature allows the system to automatically replace the supplemental pay-as-you-go instances in the scaling group with spot instances once spot instance inventory is restored.

  • Proactively compensate for interrupted instances

    By enabling the Enable Supplemental Spot Instances feature, the system creates a new spot instance to replace the old one about five minutes before it is reclaimed. This reduces the performance gap caused by spot instance interruptions.

Example: Add spot instances to a scaling group

Follow these steps to add spot instances to an existing scaling group.

Step 1: Configure vSwitches in multiple zones

Configuring vSwitches across multiple zones combines their inventory, increasing the available spot instances for the scaling group.

  1. Log on to the Auto Scaling console.

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

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

  4. Find the target scaling group and click its ID to open the details page.

image

  1. On the Basic Information tab, find the VPC section and click the edit icon image in the upper-right corner to open the Edit VPC page.

image

  1. Configure vSwitches for multiple zones, and then click OK.

    Note

    If your VPC does not have vSwitches in multiple zones, create them first. For more information, see Create and manage a vSwitch.

image

Step 2: Configure a cost optimization policy

  1. On the Basic Information tab, find the Instance Scaling Configuration section and click the edit icon image in the upper-right corner to open the Edit Instance Scaling Configuration page.

image

  1. Change the scaling policy to Cost Optimization and configure the related parameters based on your business needs. The parameters are described below:

    • Minimum Number of Pay-as-you-go Instances

      The minimum number of pay-as-you-go ECS instances required in the scaling group. The default is 0. If the number of pay-as-you-go ECS instances in the scaling group is less than this value, the system prioritizes creating pay-as-you-go instances.

    • Percentage of Pay-as-you-go Instances

      The percentage of pay-as-you-go instances among automatically created ECS instances. The default is 70%. This percentage applies to instances created beyond the number specified for Minimum Number of Pay-as-you-go Instances.

    • Lowest Cost Instance Types

      The number of lowest-cost instance types to use. The default is 1. This parameter takes effect only when multiple instance types are specified in the scaling configuration. When creating spot instances, the scaling group creates ECS instances evenly across the specified number of lowest-cost instance types.

    • Enable Supplemental Spot Instances

      When enabled, Auto Scaling proactively creates a new spot instance to replace one that is about to be reclaimed, approximately 5 minutes before the reclamation.

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

      If the required spot instance capacity cannot be met due to price or inventory issues, you can enable this feature. Auto Scaling will then attempt to create pay-as-you-go instances to fulfill the required capacity.

    • Replace Pay-as-you-go Instance with Spot Instance

      After you enable Use Pay-as-you-go Instances to Supplement Spot Capacity, the proportion of pay-as-you-go instances in the scaling group might exceed the value of Percentage of Pay-as-you-go Instances. You can enable this option to allow Auto Scaling to automatically attempt to replace the excess pay-as-you-go instances with spot instances.

image

  1. After you complete the configuration, click OK.

Step 3: Modify the scaling configuration

Note

This section shows how to modify an existing scaling configuration. You can also create a new one. For details, see Create an ECS scaling group.

  1. On the Instance Configuration Source > Scaling Configuration, find the active scaling configuration and click Edit to go to the Modify Scaling Configuration page.

image

  1. On the Modify Scaling Configuration page, change the Billing Method to Spot Instance.

image

  1. Change the instance configuration method to Specify Instance Type.

  1. Set the protection period and bidding mode for the instance. The parameters are described below:

    • Usage Duration

      This parameter specifies the spot instance's protection period. During this period, the spot instance will not be interrupted or reclaimed.
      • 1 Hour: Sets a 1-hour protection period. For one hour after the instance is created, it will not be interrupted. After one hour, the system checks inventory and bid price changes every five minutes to determine if the resource can continue to be used.

      • None: No usage duration is set. This option provides better cost savings compared to setting a usage duration.

    • Max Price Per Instance

      This parameter specifies the bidding mode for the instance.
      • Automatic Bidding: The scaling group automatically bids based on the market price of the instance, up to the price of a pay-as-you-go instance of the same type.

      • Set Maximum Price: The instance is automatically released when the market price exceeds your bid or when the supply-demand relationship changes. Make sure to back up your data.

        Use this mode to cap the instance price.

image

  1. In the Select Instance Type section, select multiple instance types to improve the scale-out success rate.

    Note

    If you set Max Price Per Instance to Set Maximum Price, you must set a bid for each instance type.

image

This example uses Automatic Bidding.
  1. After you confirm the configuration, click Edit to complete the operation.

Step 4: Verify the scale-out

After completing the configuration, trigger a scale-out activity to verify that the scaling group creates spot instances as expected. This example triggers a scale-out by modifying the expected number of instances.

Parameters

  • Percentage of Pay-as-you-go Instances: 70%.

  • Minimum Number of Pay-as-you-go Instances: 2

  • Expected Number of Instances: Changed from 0 to 12.

Expected result

9 pay-as-you-go instances and 3 spot instances.

Result calculation

After the Minimum Number of Pay-as-you-go Instances is met, the Percentage of Pay-as-you-go Instances is applied to any additional instances. Therefore, the total number of pay-as-you-go instances is , and the number of spot instances is .

Note

You can view the billing method of an instance in the ECS console.