All Products
Search
Document Center

Elastic Container Instance:Create a spot elastic container instance

Last Updated:Feb 28, 2026

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.

Warning

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.

AspectDetails
Pricing modelFluctuates based on supply and demand for the instance type
Comparison to pay-as-you-goLower prices than pay-as-you-go
Billing granularityBilled based on actual duration of use
During protection periodBilled at the market price at the time of purchase
After protection periodBilled 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 SpotDuration to 0 to disable the protection period, or keep the default of 1 hour.

Important

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 SpotAsPriceGo strategy (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 DescribeSpotPriceHistory and DescribeSpotAdvice APIs to query market price data for the last 30 days. DescribeSpotAdvice provides 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 SpotToBeReleased event. 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 SpotDuration to 0 to skip the protection period.

Creation methods

You can create a spot elastic container instance in two ways:

MethodHow it worksBilling basis
Specify ECS instance typesYou 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 memoryYou 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:

vCPUsSupported memory (GiB)
22, 4, 8, 16
44, 8, 16, 32
88, 16, 32, 64
1212, 24, 48, 96
1616, 32, 64, 128
2424, 48, 96, 192
3232, 64, 128, 256
5296, 192, 384
64128, 256, 512

Create a spot instance by using the console

  1. Go to the Create Elastic Container Instance page.

  2. Under Billing Method, select Spot Instance.抢占式

  3. 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

ParameterTypeRequiredDescription
SpotStrategystringNoBid 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).
SpotPriceLimitnumberConditionalMaximum 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.
SpotDurationintegerNoProtection 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 = 1

Create a spot instance at market price

Set the following parameters in your CreateContainerGroup request:

SpotStrategy = SpotAsPriceGo
SpotDuration = 1
Tip: If you set SpotStrategy to SpotAsPriceGo and 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

APIDescription
CreateContainerGroupCreates an elastic container instance (container group). Use spot-related parameters to create a spot instance.
DescribeSpotPriceHistoryQueries the historical market prices for spot instances over the last 30 days.
DescribeSpotAdviceQueries information such as the average release rate and average discount rate of spot instances over the last 30 days.