This topic describes how to configure a cost optimization policy for a scaling group. A cost optimization policy can be used to create multiple types of ECS instances across different zones. This increases the success rate of creating ECS instances and reduces costs.
Prerequisites
- An Alibaba Cloud account is created. To create an Alibaba Cloud account, go to the account registration page.
- A virtual private cloud (VPC) is created. For more information, see Create and manage a VPC.
- Multiple vSwitches are created across different zones of the VPC. For more information, see Work with vSwitches.
Background information
Auto Scaling supports creating ECS instances of multiple instance types in a scaling group. You can specify multiple instance types in a scaling configuration. Auto Scaling creates instances based on the priorities of the instance types. If resources of the instance type with the highest priority are insufficient, Auto Scaling automatically attempts to use the instance type with the next highest priority to create instances. This increases the success rate of creating ECS instances when resources of a specific instance type are insufficient. During business peaks, ECS instances of instance types that have higher specifications are required to respond to business requirements in a timely manner. In this case, Auto Scaling must focus on creating ECS instances with sufficient performance, instead of creating ECS instances of a specific instance type.
- Multi-zone scaling policies are available only for VPC-connected scaling groups.
- The multiple-zone scaling policy of a scaling group cannot be modified.
Auto Scaling cannot create a preemptible instance when the market price of the instance exceeds your bid. This may affect your service. To avoid this issue, you can set your multi-zone scaling policy to cost optimization policy. If a preemptible instance fails to be created, Auto Scaling automatically attempts to create a pay-as-you-go instance of the same instance type. This increases the success rate of creating ECS instances and reduces costs. You can configure a cost optimization policy and multiple instance types at the same time to further increase the success rate of scaling. Auto Scaling attempts to create ECS instances in the scaling group that applies the cost optimization policy based on the unit prices of vCPUs in ascending order. Even if you set the billing method to pay-as-you-go, the cost optimization policy ensures that you can use ECS instance resources at the lowest cost.
Procedure
Verification
No. | Instance Type | Billing method | vCPU | Market price of instance (USD per hour) | Unit price of vCPU (USD per hour) |
---|---|---|---|---|---|
Plan 1 | ecs.sn1.xlarge | Preemptible instance | 8 | 0.158 | 0.01975 |
Plan 2 | ecs.sn1.large | Preemptible instance | 4 | 0.088 | 0.022 |
Plan 3 | ecs.sn1.xlarge | Pay-as-you-go | 8 | 1.393 | 0.174125 |
Plan 4 | ecs.sn1.large | Pay-as-you-go | 4 | 0.697 | 0.17425 |
Expected process for creating instances: During a scale-out event, Auto Scaling preferentially creates ECS instances based on Plan 1. If instances fails to be created in both Zone B and Zone C due to insufficient resources, Auto Scaling attempts to create ECS instances based on Plan 2, Plan 3, and Plan 4 in sequence.
Execute the scaling rule to trigger a scale-out event during which an ECS instance is created and added to the scaling group. In the Auto Scaling console, go to the ECS Instances page of the scaling group and click the created ECS instance to view its instance type and billing method. In this example, the instance type is ecs.sn1.xlarge and the billing method is Pay-As-You-Go-Preemptible Instance. This indicates that costs are reduced.