If you configure a multi-zone scaling policy when you create a scaling group, Auto Scaling can schedule resources from other zones to the zone where resources are insufficient or faults occur. This ensures your business continuity. In addition, if you configure multiple instance types when you create a scaling configuration, the system can prevent scale-out failures caused by inventory insufficiency. This topic describes how to configure a multi-zone cost optimization policy and specify multiple instance types. This helps increase the success rate of scale-outs and reduce resource costs.
Prerequisites
A virtual private cloud (VPC) is created. For more information, see Create and manage a VPC.
Multiple vSwitches are created in the VPC. The vSwitches belong to different zones. For more information, see Create and manage a vSwitch.
Background information
Preemptible instances are subject to the market price. Failed bidding may cause delayed scale-outs, which in turn affects the normal running of your business. In this case, you can configure a scaling policy such as a cost optimization policy. When preemptible instances fail to be created, Auto Scaling automatically creates pay-as-you-go instances of the same instance types as the preemptible instances. In addition, multiple instance types can effectively prevent scale-out failures caused by insufficient inventory of a single instance type. Therefore, a scaling policy, combined with multiple instance types, greatly improves the success rate of scale-outs and reduces resource costs.
Scaling policy
When you create a scaling group in the Auto Scaling console, you can specify multiple vSwitches for the scaling group. If the zone of one of the specified vSwitches has insufficient resources, Auto Scaling automatically creates instances in another specified zone to ensure the success of scale-outs. After you specify multiple zones for a scaling group, you can configure a scaling policy such as a cost optimization policy based on the deployment of your business in the specified zones. This flexibly meets different business requirements. In a scaling group for which you configured a cost optimization policy, Auto Scaling preferentially creates instances at the lowest vCPU price. If you specified preemptible instance types, Auto Scaling preferentially creates preemptible instances. If no preemptible instance types are available, Auto Scaling creates pay-as-you-go instances of the same instance type at a comparatively lower price.
NoteA multi-zone scaling policy can be a priority policy, a balanced distribution policy, a cost optimization policy, or a custom combination policy. For more information, see Manage scaling groups.
You can configure a multi-zone scaling policy for only scaling groups that reside in VPCs.
Multiple instance types
Auto Scaling allows you to specify multiple instance types in a scaling configuration. In this case, if Auto Scaling fails to create instances by using the instance type of the highest priority, Auto Scaling automatically creates instances by using the instance type of the next highest priority until the creation succeeds. Multiple instance types effectively reduce the chance of insufficient inventory of resources and ensure all scaling activities are complete as expected. For example, during peak hours, you may need to race against time to scale out instances of higher specifications to handle business traffic. You emphasize business performance and care less about specific instance types. In this case, multiple instances provide more flexible options.
Procedure
Create a scaling group of the Elastic Compute Service (ECS) type.
For more information, see Manage scaling groups.
The following table describes the parameters that are used in this example.
Parameter
Description
Network Type
The network type of the scaling group. Select VPC.
VPC
The VPC of the scaling group. Select an existing VPC, such as
vpc-bp1idd****
.vSwitch
The vSwitches of the scaling group. Select multiple vSwitches such as
vsw1
andvsw2
.NoteA vSwitch belongs to only one zone. Multiple vSwitches provide multiple zones. After you specify multiple vSwitches for a scaling group, the ECS instances of the scaling group span the zones. Auto Scaling can make better use of the resource inventory of the zones.
Scaling Policy
The multi-zone scaling policy of the scaling group. Select Cost Optimization Policy.
Create and enable a scaling configuration.
For more information, see Create a scaling configuration of the ECS type.
The following table describes the parameters that are used in this example.
Parameter
Description
Billing Method
Select Preemptible Instance.
Instance Configuration Mode
Valid values: Specify Instance Type and Specify Instance Pattern. In this example, select Specify Instance Type.
Select Instance Type
Select multiple instance types. You can select up to 10 instance types.
We recommend that you select similar instance types in terms of vCPU, memory, processor frequency, internal bandwidth, or packet forwarding rate.
We recommend that you set a maximum bid for each instance type. If you use automatic bidding, Auto Scaling bids for and creates preemptible instances at the market price.
The configurations of I/O optimized instances vary greatly from those of non-I/O optimized instances. If you choose these two types of instances at the same time, the success rate of instance creation cannot be significantly increased.
Enable the scaling group.
Create a scaling rule.
For information about how to create a scaling rule, see the Manage scaling rules.
The following table describes the parameters that are used in this example.
Parameter
Description
Rule Type
Select Simple Scaling Rule.
Operation
Set the value to Add 1 Instances.
Execute the scaling rule.
Verify the result
After you configure a scaling policy and specify multiple instance types, your resource costs are significantly reduced. The following section describes the effect of a cost optimization policy.
Example
In this example, the vSwitches that belong to Hangzhou Zone J and Hangzhou Zone K are specified for a scaling group.
The ecs.g8y.xlarge and ecs.g8i.xlarge instance types are specified in the scaling configuration of the scaling group.
The billing method of the scaling configuration is Preemptible Instance.
Each instance type has two unit prices: the unit price of vCPUs for preemptible instances and the unit price of vCPUs for pay-as-you-go instances.
ImportantThe prices listed in the following table are used for reference only. The prices that are displayed on the instance buy page take precedence.
In the following table, ① specifies the market price of preemptible instances and ② specifies the market price of pay-as-you-go instances.
The four instance creation solutions in the following table are made based on the instance types and billing method. The solutions are arranged in ascending order based on the unit price of vCPUs.
No.
Instance type
Billing method
vCPU
Market price
Unit price of vCPUs
Solution1
ecs.g8y.xlarge
Preemptible Instance
4
0.22/hour
0.055/hour
Solution2
ecs.g8i.xlarge
Preemptible Instance
4
0.336/hour
0.084/hour
Solution3
ecs.g8y.xlarge
Pay-as-you-go
4
0.8/hour
0.2/hour
Solution4
ecs.g8i.xlarge
Pay-as-you-go
4
1.099/hour
0.275/hour
Effect
Expected result: When a scale-out is triggered in the scaling group, Auto Scaling preferentially creates preemptible ECS instances based on Solution 1. If the instance creation fails in Hangzhou Zone K and Hangzhou Zone J, Auto Scaling attempts to create ECS instances based on Solution 2, Solution 3, and Solution 4 in sequence.
Result verification: To verify the result, execute a scale-out rule to add one ECS instance to the scaling group. On the Instances tab of the Auto Scaling console, click the ID of the added ECS instance to go to the ECS console. On the Instance Details tab, view the billing method and instance type.
Billing Method: Pay-as-you-go-Preemptible Instance
Instance Type: ecs.g8y.xlarge
The actual result is the same as the expected result. Auto Scaling successfully creates one ECS instance based on Solution 1. This case proves that you can configure a cost optimization policy and specify multiple instance types at the same time to minimize resource costs.