All Products
Search
Document Center

Elastic Container Instance:Create a preemptible elastic container instance

Last Updated:Dec 26, 2023

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. This reduces the costs of elastic container instances in some scenarios.

Background information

Preemptible instances are ideal for stateless applications, such as scalable web services, image rendering, big data analytics, and large-scale parallel computing. Preemptible instances are suitable for applications that require wide distribution, high scalability, and high fault tolerance. Preemptible instances help reduce your costs and increase the throughput for these applications. For more information, see Overview.

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.

    Note

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

    Note
    • A ready-for-release event is generated about 5 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 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.

    Note

    When 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 Apsara 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. If you want to specify ECS instance types that provide less than 2 vCPUs, we recommend that you use the t5 or t6 instance families.

  • 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

    56

    224

    64

    128, 256, and 512

Configuration description

API mode

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. Valid values:

  • NoSpot: The instance is created as a regular pay-as-you-go instance.

  • SpotWithPriceLimit: The instance is created as a preemptible instance with a user-defined maximum hourly price.

  • SpotAsPriceGo: The instance is created as a preemptible instance for which the market price at the time of purchase is automatically used as the bid price.

Default value: NoSpot.

SpotPriceLimit

number

0.2

The maximum hourly price of the preemptible instance. The value can contain up to three decimal places. If you set SpotStrategy to SpotWithPriceLimit, you must specify SpotPriceLimit.

SpotDuration

long

1

The protection period of the preemptible instance. Unit: hours. Default value: 1. A value of 0 indicates no protection period.

Important

If you set SpotStrategy to SpotAsPriceGo and the resources of the specified instance specification within the specified zone are insufficient, the value that you specify for the maximum hourly price of the instance must be close to the pay-as-you-go price of the instance. This can improve the success rate of the instance creation.

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. 抢占式

Important
  • You cannot configure a bid policy. The SpotAsPriceGo bid policy is automatically used. This 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.