Elastic Container Instance supports preemptible instances. You can run stateless applications that feature high scalability and fault tolerance and short-lived jobs on preemptible instances to reduce usage costs of instances. This topic describes how to create a preemptible elastic container instance.
Background information
Preemptible elastic container instances are cost-effective. You can bid for unused Alibaba Cloud resources to create preemptible instances. When the market price exceeds your bid price for a preemptible instance or when the inventory resources are insufficient, the resources consumed by the instance are reclaimed and the instance is released.
Preemptible instances can be used to run short-lived jobs and stateless applications that feature high scalability and fault tolerance, such as scalable website services, image rendering, big data analysis, and large-scale parallel computing. Preemptible instances are suitable for applications that require wide distribution, high scalability, and high fault tolerance. Preemptible instances help you reduce costs and increase the throughput for these applications. For more information, see Preemptible instances.
Basic concepts
Before you create a preemptible instance, take note of the following items:
Billing
The market price of a preemptible instance fluctuates based on the supply and demand for its instance specification. When you create a preemptible instance, you must specify a bid policy for the instance. If your bid price is higher than the real-time market price and the resource inventory of the instance specification is sufficient, the preemptible instance is created. After a preemptible instance is created, it enters a protection period during which the instance is billed based on the market price at the time of purchase. By default, the protection period is 1 hour. After the protection period expires, the instance is billed based on the real-time market price.
NotePreemptible instances are billed at lower prices compared with pay-as-you-go instances. The price of a preemptible instance fluctuates based on the supply and demand for its instance specification. A preemptible instance is billed based on its actual duration of use. For more information, see the "Billing methods" section of the Preemptible instances topic.
Reclaim mechanism
After the protection period of a preemptible instance expires, the system checks the market price and resource inventory of the instance specification every 5 minutes. If the real-time market price exceeds your bid price or the resource inventory is insufficient, the preemptible instance is released.
NoteA ready-for-release (SpotToBeReleased) event is generated about 3 minutes before the resources of a preemptible instance are reclaimed.
After the resources of a preemptible instance are reclaimed, the information about the instance is retained, the billing on the instance stops, and the status of the instance changes to Expired.
Precautions
Before you use preemptible instances, take note of the following items:
Select a suitable instance specification and place a suitable bid.
You can call the following API operations of Elastic Compute Service (ECS) to query information about preemptible instances over the last 30 days. Then, you can select a suitable instance specification and place a bid.
DescribeSpotPriceHistory: queries the historical prices of preemptible instances.
DescribeSpotAdvice: queries information such as the average release rate and average discount rate of preemptible instances.
ImportantWhen you place a bid, take into consideration the fluctuations in market prices and the price range that you are comfortable with. A good bid is usually higher than the average market price, but still within the range of your business requirements. In this way, requests for creating preemptible instances can be accepted and processed, and the created instances will not be released due to changes in market prices.
We recommend that you store important data in a storage medium that will not be affected if preemptible instances are released. For example, you can use independent disks that are not to be released along with their associated instances, or use external storage resources such as File Storage NAS file systems.
Creation methods
You can create a preemptible instance by specifying ECS instance types or the number of vCPUs and memory size.
Specify ECS instance types
The preemptible instance is billed at the real-time discounted pay-as-you-go price of the specified ECS instance type.
Specify the number of vCPUs and memory size of the instance
This method has the same effect as the method of specifying ECS instance types. The system automatically selects an ECS instance type that meets your requirements for the number of vCPUs, memory size, and prices. The created preemptible instance is billed at the real-time discounted market price of the used ECS instance type, instead of the pay-as-you-go prices of the vCPU and memory resources that are used by the elastic container instance.
Only the instances that provide two or more vCPUs can be created by using this method. The following table lists the supported vCPU and memory specifications. If the specifications that you specify are not supported by Elastic Container Instance, the system automatically uses supported higher specifications.
Number of vCPUs
Memory (GiB)
2
2, 4, 8, and 16
4
4, 8, 16, and 32
8
8, 16, 32, and 64
12
12, 24, 48, and 96
16
16, 32, 64, and 128
24
24, 48, 96, and 192
32
32, 64, 128, and 256
52
96, 192, and 384
64
128, 256, and 512
Configuration description
OpenAPI
When you can call the CreateContainerGroup API operation to create a preemptible elastic container instance, you can use the SpotStrategy parameter to specify a bid policy, the SpotPriceLimit parameter to specify a maximum hourly price, and the SpotDuration parameter to specify a protection period. The following table describes the parameters. For more information, see CreateContainerGroup.
Parameter | Type | Example | Description |
SpotStrategy | string | SpotWithPriceLimit | The bid policy for the instance. Default value: NoSpot. Valid values:
|
SpotPriceLimit | number | 0.2 | The maximum hourly price of the preemptible instance. The value can contain up to three decimal places. If you set the SpotStrategy parameter to SpotWithPriceLimit, you must specify the SpotPriceLimit parameter. |
SpotDuration | long | 1 | The protection period of the preemptible instance. Unit: hours. Default value: 1. A value of 0 indicates no protection period. |
Console mode
If you create a preemptible elastic container instance in the Elastic Container Instance console, you can select Preemptible Instance as the billing method.
The console mode does not support the following features:
You cannot configure a bid policy. The SpotAsPriceGo bid policy is automatically used. This SpotAsPriceGo bid policy specifies that the system places bids based on the real-time market price.
You must configure a non-zero protection period for preemptible instances. The default protection period is 1 hour.