Auto Scaling can automatically select the lowest-cost ECS instance type when creating elastic container instances during scale-out events. This can reduce costs compared to standard vCPU and memory pricing and makes elastic container instances eligible for reserved instances and savings plans.
Supported instance families
When you enable cost optimization, you specify which instance family Auto Scaling uses to match ECS instance types.
| Instance family | Description | Best for | References |
| Entry-level | Shared instance types. Most cost-effective, but may not provide consistent computing performance. | Workloads with low CPU utilization. | Shared instance families |
| Enterprise-level | Dedicated resources with stable performance. | Workloads that require high stability. | Overview of instance families |
| Credit entry-level | Burstable instances that use CPU credits to maintain computing performance. | Workloads with generally low CPU utilization and occasional spikes. | Overview |
Prerequisites
Before you begin, ensure that you have:
An Alibaba Cloud account.
A scaling group that contains elastic container instances. For more information, see Step 1: Create a scaling group.
Enable cost optimization
Step 1: Create a scaling configuration
Find your scaling group and click Details in the Actions column.
Click the Instance Configuration Sources tab.
On the Scaling Configurations tab, click Create Scaling Configuration.
In the Basic Settings step, locate the Container Group Configurations section.
On the Basic Mode tab, turn on Enable Cost Optimization.
Select the instance family to use: entry-level, enterprise-level, or credit entry-level.
Configure the remaining parameters based on your requirements. For more information, see Create a scaling configuration of the Elastic Container Instance type.
Click Next: Other Settings.
Confirm the settings and click Create Order.
In the confirmation message, click Enable Configuration.
Step 2: Create a scaling rule
Create a scaling rule for the scaling group. For more information, see Create scaling rules.
Step 3: Enable the scaling group
Enable the scaling group. For more information, see the "Enable or disable scaling groups" section in Manage scaling groups.
Verify the results
After a scale-out event occurs, check the elastic container instances in your scaling group:
Cost optimization takes effect -- The instance details show that Auto Scaling used the specified ECS instance type to create the elastic container instance.
Cost optimization does not take effect -- The instance details show that Auto Scaling created the elastic container instance based on vCPU and memory specifications, without using an ECS instance type.
How cost optimization selects instance types
During each scale-out event, Auto Scaling follows this process:
Queries the unit price of elastic container instances based on vCPU and memory specifications.
Filters the ECS instance types that match your requirements and compares their prices.
Selects the ECS instance type with the lowest price.
The billing outcome depends on the price comparison:
ECS instance type is cheaper -- Auto Scaling uses that ECS instance type to create the elastic container instance. The instance is billed at the ECS instance type price. Cost optimization takes effect.
No ECS instance type qualifies, or all are more expensive -- Auto Scaling creates the elastic container instance based on vCPU and memory specifications. The instance is billed at the standard vCPU and memory unit price. Cost optimization does not take effect.
Deploy applications on shared instance types or burstable instances for workloads with low CPU utilization to reduce resource costs without over-provisioning. Elastic container instances created with a specified ECS instance type are eligible for reserved instances and savings plans. For more information, see Billing.
Cost comparison example
Call the DescribeContainerGroupPrice API operation to query the cost of elastic container instances created by Auto Scaling. The following example uses the TradePrice parameter from the API response.
| Configuration | TradePrice |
| Cost optimization disabled | 0.00004085 |
| Cost optimization enabled | 0.00003387 |
In this example, enabling cost optimization reduced the cost by 17%.
ECI scaling group features
ECI scaling groups share the following features with ECS scaling groups: event-triggered tasks, lifecycle hooks, rolling updates, and notifications. ECI scaling groups also have exclusive features: image cache and cost optimization. For more information, see Feature comparison of different types of scaling groups.