A spot elastic container instance lets you use unused Elastic Container Instance capacity at a significant discount compared to pay-as-you-go pricing. The tradeoff is that Alibaba Cloud may reclaim your instance when the market price exceeds your bid or when inventory runs low.
Spot instances can be reclaimed at any time after the protection period ends. Do not use them for workloads that require guaranteed uptime or that cannot tolerate interruption.
Ideal workloads: Stateless, fault-tolerant tasks such as batch processing, big data analysis, image rendering, large-scale parallel computing, and scalable web services.
Pricing and billing
The price of a spot elastic container instance fluctuates based on real-time supply and demand for the underlying instance type. When you create a spot instance, you specify a bid policy. If your bid price is higher than the current market price and sufficient resources are available, your instance is created.
| Aspect | Details |
|---|---|
| Pricing model | Fluctuates based on supply and demand for the instance type |
| Comparison to pay-as-you-go | Lower prices than pay-as-you-go |
| Billing granularity | Billed based on actual duration of use |
| During protection period | Billed at the market price at the time of purchase |
| After protection period | Billed at real-time market price |
Protection period
Every spot elastic container instance enters a protection period immediately after creation. During this period, the instance is billed at the market price at the time of purchase and cannot be reclaimed due to price or inventory changes.
Default duration: 1 hour
Configurable: Set
SpotDurationto0to disable the protection period, or keep the default of1hour.
After the protection period ends, the system checks the market price and resource inventory every 5 minutes. If the real-time market price exceeds your bid price, or if inventory is insufficient, the instance is released.
Reclaim process
When the system determines that a spot instance must be reclaimed (after the protection period), the following sequence occurs:
Protection period ends
|
v
System checks price & inventory (every 5 minutes)
|
v (price exceeds bid OR inventory insufficient)
SpotToBeReleased event triggered ── ~3 min warning
|
v
Instance released ── instance information is retained, billing stops, status changes to "Expired"Tip: Subscribe to SpotToBeReleased events to gracefully shut down your application, flush buffers, and checkpoint state before the instance is reclaimed. You have approximately 3 minutes between the event and actual release.Limitations
Spot instances can be reclaimed at any time after the protection period ends due to price or inventory changes.
When creating instances by specifying vCPU and memory, a minimum of 2 vCPUs is required.
If the exact vCPU and memory specifications you request are not supported, the system automatically provisions the next higher supported configuration.
The console does not support configuring a custom bid policy. All spot instances created through the console automatically use the
SpotAsPriceGostrategy (market price as bid).The console requires a non-zero protection period and defaults to 1 hour.
Before you begin
Research market prices. Use the
DescribeSpotPriceHistoryandDescribeSpotAdviceAPIs to query market price data for the last 30 days.DescribeSpotAdviceprovides information such as the average release rate and average discount rate of spot instances. Set your bid higher than the average market price to reduce the risk of immediate reclaim.Design for interruption. Store important data on independent disks or external storage services such as NAS file systems or OSS buckets. Do not rely on the local storage of a spot instance for persistent data.
Handle the
SpotToBeReleasedevent. Implement a listener for this event to perform graceful shutdown operations. You have approximately 3 minutes between the event and actual reclaim.Combine with regular instances for critical workloads. Run your baseline capacity on pay-as-you-go instances and use spot instances to handle peak loads. This gives you cost savings without sacrificing reliability.
Disable the protection period for ultra-short jobs. If your workload completes in minutes, set
SpotDurationto0to skip the protection period.
Creation methods
You can create a spot elastic container instance in two ways:
| Method | How it works | Billing basis |
|---|---|---|
| Specify ECS instance types | You explicitly select one or more ECS instance types. | Billed at the real-time discounted pay-as-you-go price of the specified instance type. |
| Specify vCPU and memory | You specify the vCPU and memory requirements. The system automatically selects a matching ECS instance type. | Billed at the real-time discounted market price of the automatically selected instance type, not at the pay-as-you-go prices of the vCPU and memory resources. |
Supported vCPU and memory combinations
When you use the vCPU and memory method, choose from the following supported combinations:
| vCPUs | Supported memory (GiB) |
|---|---|
| 2 | 2, 4, 8, 16 |
| 4 | 4, 8, 16, 32 |
| 8 | 8, 16, 32, 64 |
| 12 | 12, 24, 48, 96 |
| 16 | 16, 32, 64, 128 |
| 24 | 24, 48, 96, 192 |
| 32 | 32, 64, 128, 256 |
| 52 | 96, 192, 384 |
| 64 | 128, 256, 512 |
Create a spot instance by using the console
Go to the Create Elastic Container Instance page.
Under Billing Method, select Spot Instance.

Complete the remaining instance configuration (region, VPC, vSwitch, security group, container image, vCPU, and memory) and confirm creation.
The console does not support configuring a custom bid policy. All spot instances created through the console automatically use the SpotAsPriceGo strategy (market price as bid). The protection period defaults to 1 hour and cannot be changed in the console.Create a spot instance by using the API
Call the CreateContainerGroup operation with the spot-related parameters described below.
API parameter reference
| Parameter | Type | Required | Description |
|---|---|---|---|
SpotStrategy | string | No | Bid policy for the spot instance. Valid values: NoSpot (default, creates a regular pay-as-you-go instance), SpotWithPriceLimit (spot instance with a maximum hourly price you define; requires SpotPriceLimit), SpotAsPriceGo (spot instance that uses the current market price as the bid). |
SpotPriceLimit | number | Conditional | Maximum hourly price you are willing to pay. Supports up to 3 decimal places (for example, 0.025). Required when SpotStrategy is set to SpotWithPriceLimit. Ignored for other strategies. |
SpotDuration | integer | No | Protection period in hours. Valid values: 1 (default, instance is protected from reclaim for 1 hour after creation), 0 (no protection period; the instance can be reclaimed at any time based on price and inventory). |
Examples
Create a spot instance with a price cap
Set the following parameters in your CreateContainerGroup request:
SpotStrategy = SpotWithPriceLimit
SpotPriceLimit = 0.025
SpotDuration = 1Create a spot instance at market price
Set the following parameters in your CreateContainerGroup request:
SpotStrategy = SpotAsPriceGo
SpotDuration = 1Tip: If you setSpotStrategytoSpotAsPriceGoand resources of the specified instance type are insufficient, set your maximum hourly price to approximate the pay-as-you-go price of the instance. This can improve the success rate of instance creation.
Related API operations
| API | Description |
|---|---|
| CreateContainerGroup | Creates an elastic container instance (container group). Use spot-related parameters to create a spot instance. |
| DescribeSpotPriceHistory | Queries the historical market prices for spot instances over the last 30 days. |
| DescribeSpotAdvice | Queries information such as the average release rate and average discount rate of spot instances over the last 30 days. |