Preemptible instances are on-demand instances. They are designed to reduce your ECS costs in some cases. When you create a preemptible instance, you can set a maximum price per hour to bid for a specified instance type. If your bid is higher than or equal to the current market price, your instance is created. A preemptible instance is held without interruption for at least one hour after it is created. After one hour, your bid is compared with the market price every five minutes. When the market price exceeds your bid or the resource stock is insufficient, the instance is automatically released. The following figure shows the life cycle of a preemptible instance.
Preemptible instances are ideal for stateless applications, such as scalable Web services and applications for rendering figures, big data analysis, and massively parallel computing. Applications requiring higher level of distribution, scalability, and fault tolerance capability benefit from preemptible instances with respect to costs and throughput.
You can deploy the following businesses on preemptible instances:
- Real-time analysis
- Big data
- Geological surveys
- Image coding and media coding
- Scientific computing
- Scalable Web sites and Web crawlers
- Image and media coding
Preemptible instances are not suitable for stateful applications, such as databases, because it is difficult to store application states if the instance is released because of a failed bid or other reasons.
You can bid for a preemptible instance only one time in either of the following bidding modes:
In this mode, you must set the highest price you want to pay for a specified instance type. When creating a preemptible instance by using RunInstances, you can bid in this mode.
Currently, the maximum bid of a preemptible instance is the price of a Pay-As-You-Go instance of the same configuration. When creating a preemptible instance, you can set a price according to the market price history, business features, and the estimated future price fluctuation. When the market price is lower than or equal to your bid, and the resource stock is sufficient, the instance continues to run. If your estimated quote is accurate, you can hold the instance after the one hour guaranteed duration. Otherwise, your instance can get automatically released at any time.
When creating a preemptible instance by using RunInstances, you can create a preemptible instance with the SpotAsPriceGo bidding mode by setting
SpotAsPriceGo, which means you always set the real-time market price as the bidding price until the instance is released because of stock shortage.
When a preemptible instance is created, it has a guaranteed duration of one hour, namely, the first hour after it is run. During this period, the instance is not released because of stock shortage, and you can run services on the instance as usual. Beyond the guaranteed duration, the market price and stock is checked every five minutes. If the market price at any given point in time is higher than your bid or the instance type stock is insufficient, your preemptible instance will be automatically released.
Price and billing
Preemptible instance price and billing considerations:
The preemptible instance price applies to the instance type only, including vCPU and memory, but not to system disks, data disks, or network bandwidth. The prices for system disks, data disks, or network bandwidth are the same as for Pay-As-You-Go instances.
Preemptible instances are billed on an hourly basis during their life cycles. You are billed for the entire hour even if your usage is less than an hour.
Instances are billed according to the actual period of use. The actual period of use is the duration from instance creation to instance release. After an instance is released, it is no longer billed. If you stop the instance by using StopInstance or in the ECS console, the instance continues to be billed.
During creation of a preemptible instance, it runs when your bid is higher than the current market price and the relevant demand and supply conditions are satisfied. The final price you pay for your instance type is based on the current market price.
The actual market price of a preemptible instance fluctuates according to the changes in the demand and supply of a given instance type, and you can take advantage of these price fluctuations. If you purchase preemptible instance types at the right time, the computing costs are reduced, whereas your throughput is increased for the period the instance is held.
For more information about the preemptible instance quota, see Limits.
Create a preemptible instance
You can purchase a preemptible instance by using the RunInstances interface.
After a preemptible instance is created, it can be used in exactly the same way as a Pay-As-You-Go instance. You can also use it with other cloud products, such as cloud disks or EIP addresses.
Stop a preemptible instance
You can stop a preemptible instance in the ECS console or by using the StopInstance interface. The VPC-Connected preemptible instances support the No fees for stopped instances (VPC-Connected) feature.
The network type and the bidding mode of a preemptible instance determine whether it can start after it is stopped, as displayed in the following table.
|Network type + Bidding mode||Stop instance||Start instance|
|VPC + SpotWithPriceLimit||Keep Instance, Fees Apply||During the guaranteed duration, the instance can be started successfully. After the guaranteed duration:
|Classic + SpotWithPriceLimit||N/A|
|VPC + SpotAsPriceGo||Keep Instance, Fees Apply||During the guaranteed duration, the instance can be started successfully. After the guaranteed duration:
|Classic + SpotAsPriceGo||N/A|
|VPC + SpotWithPriceLimit||Stop Instance, No Fees||During the guaranteed duration, the instance can be started successfully only if the resource stock is sufficient. After the guaranteed duration:
|VPC + SpotAsPriceGo||Stop Instance, No Fees||During the guaranteed duration, the instance can be started successfully only if the resource stock is sufficient. After the guaranteed duration:
Release a preemptible instance
When the guaranteed period ends, we automatically release your preemptible instance because of changes in the market price or short resource stock. Additionally, you can independently release the instance.
When a preemptible instance is released because of market price or changes in the demand and supply of resources, the instance's status changes to Pending Release. Then, the instance is released in about five minutes. You can use instance metadata or the
OperationLocks information returned by calling the DescribeInstances interface to check if an instance is in the Pending Release status.
|Although you can check if a preemptible instance is in the Pending Release status by using the API and save a small amount of data while the instance is in this status, we recommend that you design your applications so work can be properly resumed if the preemptible instance is immediately released. When you release the instance manually, you can test whether or not your application functions normally if a preemptible instance is immediately recovered.|
Generally, we release preemptible instances in the order of bidding price, from low to high. If multiple preemptible instances have the same bidding price, they are randomly released.
When using a preemptible instance, consider the following:
Set an appropriate bidding price. In other words, you must quote a competitive price to meet your business budget and hedge against the future market price fluctuations. By using this price, your preemptible instance can be created. In addition, the price must meet your expectations based on your own business assessment.
The image must have all the software configurations that your applications need, assuring that you can run your business immediately after the instance is created. Additionally, you can use User-defined data to run commands at startup.
Store your business data on storage products that are independent from preemptible instances, such as cloud disks that are not set to release together with instances, OSS, or RDS.
Split your tasks by using grids, Hadoop, queuing-based architecture, or check points, to facilitate store computing results frequently.
Use the release notification to monitor the status of a preemptible instance. You can use metadata to check the instance status every minute. The metadata of an instance is updated five minutes before it is released automatically.
Test your applications in advance, to make sure that they can handle events such as accidental release of an instance. To test the applications: Run the applications on a Pay-As-You-Go instance, release the instance, and then check how the applications can handle the release.
For more information, see FAQ about preemptible instances.
For more information about using APIs to create preemptible instances, see Use APIs to manage preemptible instances.