An auto provisioning group creates and manages a fleet of Elastic Compute Service (ECS) instances across multiple instance types, zones, and pricing models. Use auto provisioning groups to build instance clusters that balance cost, availability, and capacity for workloads such as machine learning and web services.
Choose a configuration strategy
Select the strategy that matches your workload before you configure an auto provisioning group.
| Scenario | Configuration | Details |
|---|---|---|
| Optimize for cost-effectiveness and high creation success rate? | Capacity Optimization Policy (default) | Uses the most cost-effective instance type based on the prices and reclamation rates of spot instances. |
| Minimize costs across multiple resource pools? | Cost Optimization Policy with spot instances | The auto provisioning group selects the lowest-priced instance type to create instances. |
| Distribute instances across zones for disaster recovery? | Balanced Distribution Policy | The auto provisioning group evenly creates instances across zones to prevent instance creation failures caused by insufficient resources within a single zone. |
| Prioritize a specific instance type (for example, to use reserved instances)? | Prioritized allocation (PayAsYouGoAllocationStrategy = prioritized) | Creates pay-as-you-go instances based on the priority specified by LaunchTemplateConfig.N.Priority. |
| Use multiple low-cost pools to reduce spot interruption risk? | Lowest-price allocation with SpotInstancePoolsToUseCount | Distributes spot instances across the N cheapest resource pools instead of concentrating in one. |
Core concepts
| Concept | Description |
|---|---|
| Resource pool | A combination of one instance type and one zone. Each pool is an independent source of capacity. |
| Target capacity | The total capacity goal for the group, measured in instances or vCPUs. |
| Weighted capacity | The weight assigned to an instance type relative to the target capacity. When target capacity is measured in vCPUs, a 4-vCPU instance type has a weight of 4. |
| Provisioning policy | The strategy that determines how instances are allocated across resource pools. |
| Group type | Controls whether the group delivers instances once (One-time Delivery) or maintains capacity continuously (Continuous Delivery and Maintain Capacity). |
Spot instance interruption handling
When a spot instance is reclaimed, the auto provisioning group handles it based on the Spot Instance Interruption Settings that you select.
| Setting | Behavior | Recovery time | Cost after interruption |
|---|---|---|---|
| Release | The instance is released and its resources are freed. | Longer: a new instance must be created. | No charges continue. |
| Stop | The instance enters economical mode (stopped) and can be restarted when capacity is available. | Shorter: restarting is faster than creating a new instance. | No compute charges. Storage charges continue. |
Configure in the ECS console
Example 1: Machine learning cluster (cost-optimized)
Scenario: Complete a week-long machine learning task analyzing risk factors in mortgage loans. The cluster needs GPU instances, costs should be minimized, and all instances should be released when the task completes.
Requirements:
Region: China (Hangzhou)
GPU: NVIDIA V100, up to 32 GB GPU memory per instance
Target capacity: 20 instances
To minimize costs, create only spot instances. The number of instances in the instance cluster can be less than the target capacity.
Instances must be released after the task is completed
Configuration:
| Section | Parameter | Setting |
|---|---|---|
| Capacity Configuration | Target Capacity | Select Instances from the drop-down list. Set the value to 20. |
| Instance Configuration | Instance Configuration | 1. Select the ecs.gn6v-c8g1.2xlarge and ecs.gn6e-c12g1.3xlarge instance types. These are equipped with NVIDIA V100 GPUs and have up to 32 GB GPU memory. 2. Check instance type availability in Hangzhou Zone H and Hangzhou Zone I on the ECS Instance Types Available for Each Region page. 3. Add two instance configurations: one with a vSwitch in Hangzhou Zone H, and another with a vSwitch in Hangzhou Zone I. Add both instance types to each configuration. |
| Provisioning Policy | Select Cost Optimization Policy. The group creates instances from the cheapest available resource pool. | |
| Spot Instance Interruption Settings | Select Release. The number of instances in the instance cluster can be less than the target capacity to minimize costs. | |
| Advanced | Group Type | Select One-time Delivery. The number of instances in the instance cluster can be less than the target capacity to minimize costs. |
| Start Time and End Time | Set the start and end times to cover the one-week task period. | |
| Global Maximum Price for Spot Instances | Select Set Maximum Price and specify a maximum price that you can afford. | |
| Instance Shutdown Settings | Select Shut Down Instances Upon Group Expiration to release all instances when the task completes. Select Shut Down Excessive Instances When Target Capacity Is Exceeded to minimize costs. |
This configuration forms four resource pools:
| Resource pool | Instance type | Zone |
|---|---|---|
| 1 | ecs.gn6v-c8g1.2xlarge | Hangzhou Zone H |
| 2 | ecs.gn6e-c12g1.3xlarge | Hangzhou Zone H |
| 3 | ecs.gn6v-c8g1.2xlarge | Hangzhou Zone I |
| 4 | ecs.gn6e-c12g1.3xlarge | Hangzhou Zone I |
The group evaluates all four pools and creates instances from the cheapest available pool.
For details about these instance types, see Overview of instance families.
Example 2: Ticketing website (high availability)
Scenario: Build a ticketing website that provides reliable service at all hours, including peak traffic. The cluster must sustain a minimum capacity using pay-as-you-go instances and span multiple zones for disaster recovery.
Requirements:
Region: China (Hangzhou)
Instance type: up to 8 vCPUs per instance (c6 family, suitable for frontend web servers)
Target capacity: 80 vCPUs
Minimum capacity: 60 vCPUs (guaranteed by pay-as-you-go instances)
Disaster recovery across multiple zones
Configuration:
| Section | Parameter | Setting |
|---|---|---|
| Capacity Configuration | Target Capacity | Select vCPUs from the drop-down list. Set the value to 80. Select Use Pay-as-you-go Instances to Provide Computing Power. |
| Pay-as-you-go Instance Capacity | Set to 60 to guarantee the minimum capacity. | |
| Instance Configuration | Instance Configuration | 1. Select the ecs.c6.large, ecs.c6.xlarge, and ecs.c6.2xlarge instance types. 2. Check availability in Hangzhou Zone H, Hangzhou Zone I, and Hangzhou Zone J. 3. Add three instance configurations, one per zone, each with all three instance types. |
| Provisioning Policy | Select Balanced Distribution Policy. The group evenly creates instances across zones to prevent instance creation failures caused by insufficient resources within a single zone, improving disaster recovery. | |
| Spot Instance Interruption Settings | Select Stop to ensure that the website can be accessed at a low latency. The time required to recover an instance from stopping in economical mode is less than the time required to create an instance. | |
| Advanced | Group Type | Select Continuous Delivery and Maintain Capacity to continuously provide ticketing service. |
| Start Time and End Time | The auto provisioning group immediately starts and can be indefinitely retained to continuously provide ticketing service. | |
| Global Maximum Price for Spot Instances | Select Automatic Bidding to maintain a stable number of instances in the cluster. | |
| Instance Shutdown Settings | Select Shut Down Excessive Instances When Target Capacity Is Exceeded to minimize costs. |
This configuration forms nine resource pools (3 instance types x 3 zones):
| Resource pool | Instance type | Zone |
|---|---|---|
| 1 | ecs.c6.large | Hangzhou Zone H |
| 2 | ecs.c6.xlarge | Hangzhou Zone H |
| 3 | ecs.c6.2xlarge | Hangzhou Zone H |
| 4 | ecs.c6.large | Hangzhou Zone I |
| 5 | ecs.c6.xlarge | Hangzhou Zone I |
| 6 | ecs.c6.2xlarge | Hangzhou Zone I |
| 7 | ecs.c6.large | Hangzhou Zone J |
| 8 | ecs.c6.xlarge | Hangzhou Zone J |
| 9 | ecs.c6.2xlarge | Hangzhou Zone J |
How the balanced distribution policy works
When target capacity is measured in vCPUs, each instance type has a weight equal to its vCPU count.
| Instance type | vCPUs | Pay-as-you-go price (USD) | Weight | Weighted price (USD) |
|---|---|---|---|---|
| ecs.c6.large | 2 | 0.06 per hour | 2 | 0.03 per hour |
| ecs.c6.xlarge | 4 | 0.121 per hour | 4 | 0.03025 per hour |
| ecs.c6.2xlarge | 8 | 0.241 per hour | 8 | 0.030125 per hour |
Prices are for reference only. Actual prices on the buy page prevail.
The group follows this allocation sequence:
Distribute across zones: Create instances evenly in Hangzhou Zone H, Zone I, and Zone J.
Select by weighted price: Within each zone, prefer instance types with lower weighted prices.
Random tiebreak: If weighted prices are equal, select an instance type at random.
Configure by calling an API operation
Use the CreateAutoProvisioningGroup API operation to create auto provisioning groups programmatically.
Example 1: Distribute across lowest-price pools
If you want to minimize costs and alleviate the impact of spot instance reclamation caused by using a single resource pool, you can configure an auto provisioning group to use multiple resource pools that have the lowest prices to create instances.
Goal:
Create 30 spot instances from a launch template with five resource pools
Use the three cheapest pools, creating 10 instances from each
API parameters:
| Parameter | Value | Description |
|---|---|---|
TotalTargetCapacity | 30 | Total target: 30 instances |
SpotTargetCapacity | 30 | All 30 are spot instances |
PayAsYouGoTargetCapacity | 0 | No pay-as-you-go instances |
SpotAllocationStrategy | lowest-price | Select pools by price, lowest first |
SpotInstancePoolsToUseCount | 3 | Use the 3 cheapest pools out of the 5 available |
PayAsYouGoAllocationStrategy | lowest-price | Cost optimization for pay-as-you-go (not used in this example because the count is 0) |
LaunchTemplateId | lt-bp1ivgo4p5now3px**** | The launch template that defines base instance settings |
Resource pool configurations (LaunchTemplateConfig):
| Pool | Parameter prefix | vSwitch ID | Instance type | Weighted capacity |
|---|---|---|---|---|
| 1 | LaunchTemplateConfig.1 | vsw-bp1ygryo03m39xhsy**** | ecs.c6e.large | 1 |
| 2 | LaunchTemplateConfig.2 | vsw-bp16hgf8f3kvtcbyu**** | ecs.c6e.xlarge | 1 |
| 3 | LaunchTemplateConfig.3 | vsw-bp1oeawdo9tj2gvjp**** | ecs.c6e.2xlarge | 1 |
| 4 | LaunchTemplateConfig.4 | vsw-bp1oeawdo9tj2gvjp**** | ecs.g6e.xlarge | 1 |
| 5 | LaunchTemplateConfig.5 | vsw-bp1oeawdo9tj2gvjp**** | ecs.g6e.2xlarge | 1 |
Result: The group ranks all five pools by current spot price and creates instances from the three cheapest pools, distributing 10 instances to each.
Example 2: Prioritize a specific resource pool
You can configure an auto provisioning group to create instances by preferentially using a specific resource pool. For example, if you use reserved instances that can be applied to ecs.c6e.large instances, you can configure an auto provisioning group to preferentially select the ecs.c6e.large instance type to benefit from the billing discounts provided by the reserved instances.
Goal:
Create 20 instances: 10 spot and 10 pay-as-you-go
Create pay-as-you-go instances from the ecs.c6e.large pool first (priority 0 = highest)
API parameters:
| Parameter | Value | Description |
|---|---|---|
TotalTargetCapacity | 20 | Total target: 20 instances |
SpotTargetCapacity | 10 | 10 spot instances |
PayAsYouGoTargetCapacity | 10 | 10 pay-as-you-go instances |
SpotAllocationStrategy | lowest-price | Select spot pools by price |
PayAsYouGoAllocationStrategy | prioritized | Create pay-as-you-go instances by pool priority |
LaunchTemplateId | lt-bp1ivgo4p5now3px**** | The launch template |
Resource pool configurations (LaunchTemplateConfig):
| Pool | Parameter prefix | vSwitch ID | Instance type | Weighted capacity | Priority |
|---|---|---|---|---|---|
| 1 | LaunchTemplateConfig.1 | vsw-bp1ygryo03m39xhsy**** | ecs.c6e.large | 1 | 0 (highest) |
| 2 | LaunchTemplateConfig.2 | vsw-bp16hgf8f3kvtcbyu**** | ecs.c6e.xlarge | 1 | -- |
| 3 | LaunchTemplateConfig.3 | vsw-bp1oeawdo9tj2gvjp**** | ecs.c6e.2xlarge | 1 | -- |
| 4 | LaunchTemplateConfig.4 | vsw-bp1oeawdo9tj2gvjp**** | ecs.g6e.xlarge | 1 | -- |
| 5 | LaunchTemplateConfig.5 | vsw-bp1oeawdo9tj2gvjp**** | ecs.g6e.2xlarge | 1 | -- |
Result: The group creates 10 pay-as-you-go instances from the ecs.c6e.large pool (priority 0). If that pool has insufficient capacity, it falls back to pools 2-5. Spot instances are created from the cheapest available pool.
A priority value of0indicates the highest priority. Only set priority on pools used with theprioritizedallocation strategy.