Reduce costs with scaling policy and instance types
When you create a scaling group, you can configure a multi-zone scaling policy. This ensures that if one zone experiences resource shortages or failures, the scaling group can provision resources in other zones to maintain high availability for your applications. You can also specify multiple instance types in a scaling configuration to prevent scaling activities from failing due to insufficient inventory of a single instance type. This topic describes how to use a cost optimization policy across multiple zones and specify multiple instance types to increase the success rate of scaling activities and reduce costs.
Prerequisites
-
A VPC is created. For more information, see Create and manage a VPC.
-
Multiple vSwitches are created in the VPC. The vSwitches are distributed across different zones. For more information, see Create and manage vSwitches.
Background
Spot instances are subject to market price fluctuations, and a failed bid can delay scale-outs and disrupt your services. To mitigate this, you can use a scaling policy from Auto Scaling, such as a cost optimization policy. If a spot instance cannot be created, the scaling group automatically attempts to create a pay-as-you-go instance of the same type. Additionally, specifying multiple instance types can effectively handle insufficient inventory of a single instance type, ensuring successful scaling activities. Therefore, using a scaling policy in combination with multiple instance types significantly increases the success rate of scaling activities and reduces costs.
-
Scaling policy
Auto Scaling allows you to specify multiple vSwitches when you create a scaling group. If the zone where a vSwitch resides has insufficient inventory, Auto Scaling automatically attempts to create instances in other specified zones to ensure the scaling activity succeeds. After you configure multiple zones, you can also set a corresponding scaling policy, such as a cost optimization policy. A scaling group that uses a cost optimization policy attempts to create ECS instances starting from the lowest vCPU unit price. This allows you to obtain ECS resources at a lower cost, even if you do not select spot instances.
Note-
Multi-zone scaling policies include the priority policy, balanced distribution policy, cost optimization policy, or a custom composite policy. For more information, see Configure a scaling group.
-
A multi-zone scaling policy applies only to scaling groups whose network type is VPC.
-
-
Multiple instance types
Auto Scaling allows you to specify multiple instance types in a scaling configuration. If an instance of a higher-priority type cannot be created, Auto Scaling automatically attempts to create an instance of the next-priority type until an instance is successfully created. This approach helps overcome insufficient inventory of a single instance type, ensuring that scaling activities can complete. For example, during peak business hours, you may need to quickly provision high-spec instances to handle traffic. In such scenarios, where performance is more critical than a specific instance type, using multiple instance types provides the necessary flexibility to meet demand.
Procedure
-
Create a scaling group for ECS instances.
For more information, see Configure a scaling group.
The following table describes the key parameters.
Parameter
Description
Network Type
Select VPC.
VPC
Select an existing VPC, such as
vpc-bp1idd****.vSwitch
Select multiple existing vSwitches in the VPC, such as
vsw1andvsw2.NoteBecause each vSwitch belongs to a single zone, selecting multiple vSwitches allows you to use inventory from multiple zones.
Scaling Policy
For the multi-zone scaling policy, select Cost Optimization Policy.
-
Create and enable a scaling configuration.
For more information, see Create a scaling configuration for ECS instances.
The following table describes the key parameters.
Parameter
Description
Billing Method
Select Spot Instance.
Instance Configuration Mode
Select Specify Instance Type or Specify Instance Pattern. In this example, Specify Instance Type is selected.
Select Instance Type
Select multiple instance types. You can select a maximum of 10 instance types.
-
We recommend that you select instance types that are similar in terms of vCPUs, memory, processor frequency, internal bandwidth, or packet forwarding rate.
-
We recommend that you set a maximum price based on your budget. If you use automatic bidding, the scaling group bids at the market price for spot instances and creates instances accordingly.
-
Because I/O optimized and non-I/O optimized instances have significantly different configurations, selecting both types together is unlikely to increase the scaling success rate.
-
-
Enable the scaling group.
-
Create a scaling rule.
For more information, see Configure a scaling rule.
The following table describes the key parameters.
Parameter
Description
Rule Type
Select Simple Scaling Rule.
Operation
Set to Add 1 instance.
-
Execute the scaling rule.
Example
After you configure a scaling policy and multiple instance types, you can significantly reduce costs.
Setup
-
The scaling group is configured with vSwitches in two zones: China (Hangzhou) Zone J and China (Hangzhou) Zone K.
-
The scaling configuration specifies two instance types: ecs.g8y.xlarge and ecs.g8i.xlarge.
-
The Spot Instance is set to spot instance.
-
Each instance type corresponds to two vCPU unit prices: one for spot instances and one for pay-as-you-go instances.
ImportantThe prices listed below are for example purposes only. The actual price is determined at the time of purchase on the buy page.

① indicates the market price of spot instances and ② indicates the market price of pay-as-you-go instances.
Combining the instance types and billing methods yields four instance creation solutions, sorted by vCPU unit price from lowest to highest:
Solution
Instance type
Billing method
vCPU
Market price
vCPU unit price
Solution 1
ecs.g8y.xlarge
spot instance
4
USD 0.22/hour
USD 0.055/hour
Solution 2
ecs.g8i.xlarge
spot instance
4
USD 0.336/hour
USD 0.084/hour
Solution 3
ecs.g8y.xlarge
pay-as-you-go
4
USD 0.8/hour
USD 0.2/hour
Solution 4
ecs.g8i.xlarge
pay-as-you-go
4
USD 1.099/hour
USD 0.275/hour
Verification
-
Expected result: When a scale-out activity is triggered in the scaling group, Auto Scaling first attempts to create an ECS instance based on Solution 1. If the instance cannot be created in either China (Hangzhou) Zone J or China (Hangzhou) Zone K, Auto Scaling sequentially attempts Solution 2, Solution 3, and Solution 4.
-
Verification: After you execute the scaling rule to trigger a scaling activity, one ECS instance is added to the scaling group. In the Auto Scaling console, go to the Instances tab and click the ID of the automatically created ECS instance. You are redirected to the Instance Details page in the ECS console where you can check the billing method and instance type.
-
Billing Method: Spot Instance
-
Instance type: ecs.g8y.xlarge
As expected, an ECS instance is successfully created based on Solution 1. This demonstrates that using a scaling policy in combination with multiple instance types can significantly reduce costs. -