Preemptible instances support multiple bidding modes. You can select a bidding mode
based on your business requirements. This topic compares and analyzes different bidding
modes of preemptible instances and provides best practices for bidding modes.
Background information
Preemptible instances are a type of on-demand instances that are offered at a discounted
price compared to pay-as-you-go instances. Preemptible instances are designed to minimize
Elastic Compute Service (ECS) instance costs in specific scenarios. Preemptible instances
support the following bidding modes:
- Set Maximum Price (SpotWithPriceLimit)
- Use Automatic Bid (SpotAsPriceGo)
This topic also provides a bidding mode that combines Use Automatic Bid (SpotAsPriceGo)
with the ACS-ECS-AlarmWhenDiscountAndPriceExceedsThresholdInMultiZoneAndInstanceType
public template of Operation Orchestration Service (OOS). This mode helps control
costs while reducing the probability of preemptible instance interruptions.
Comparison of bidding modes
- Mode 1: Set Maximum Price (SpotWithPriceLimit)
You must specify a maximum hourly price to bid for the instance type. If the spot
price (current market price per hour) of the instance type exceeds your specified
maximum hourly price due to price fluctuations, a preemptible instance interruption
event is triggered.
Analysis:
- Advantage: Costs are controlled to ensure that the instance type fees do not exceed
the maximum hourly price that you specify.
- Disadvantage: If the instance type price drastically fluctuates, the probability of
instance interruptions increases and instance stability decreases.
- Applicable scenario: business that has strict budget and price requirements for ECS
instances, of which the budget cannot be exceeded.
- Mode 2: Use Automatic Bid (SpotAsPriceGo)
In this mode, the preemptible instance is billed based on the spot price.
Analysis:
- Advantage: The instance is not interrupted even if the instance type price drastically
fluctuates, and instance stability is improved.
- Disadvantages: It is difficult to control costs. Increases in instance type prices
cannot be detected and costs can spiral uncontrollably.
- Applicable scenario: business that has no strict cost requirements and requires to
reduce costs as much as possible while improving instance stability.
- Mode 3: Combination of Use Automatic Bid (SpotAsPriceGo) and OOS
In the Use Automatic Bid (SpotAsPriceGo) mode, increases in instance type prices cannot
be detected. When the ACS-ECS-AlarmWhenDiscountAndPriceExceedsThresholdInMultiZoneAndInstanceType
public template of OOS is combined with Use Automatic Bid (SpotAsPriceGo), OOS sends
a notification when the price of the preemptible instance exceeds the threshold of
the instance type that you specify. This way, you can manage the preemptible instance.
Analysis:
- Advantage: Increases in instance type prices can be detected and the instance is stable.
- Disadvantage: The Use Automatic Bid (SpotAsPriceGo) mode must be combined with OOS,
which increases costs.
- Applicable scenario: business that requires the ability to detect price increases
while improving instance stability.
The following table compares the bidding modes.
Bidding mode |
Instance interruption probability |
Instance stability |
Cost optimization |
Cost controllability |
Set Maximum Price (SpotWithPriceLimit) |
High |
Low |
High |
High |
Use Automatic Bid (SpotAsPriceGo) |
Low |
High |
Slightly high |
Slightly low |
Best practices for bidding modes
Preemptible instances support the following bidding modes. You can select a bidding
mode based on your business requirements:
- If you require a strict control over your budgets but do not require high instance
stability, you can select Set Maximum Price (SpotWithPriceLimit).
- If you require high instance stability but do not require a strict control over your
costs, you can select Use Automatic Bid (SpotAsPriceGo).
If you require both instance stability and cost control, you can refer to the following
steps to use the SpotAsPriceGo+OOS
mode. You can use the Use Automatic Bid (SpotAsPriceGo)
mode to increase instance stability and use the ACS-ECS-AlarmWhenDiscountAndPriceExceedsThresholdInMultiZoneAndInstanceType
public template of OOS to monitor the price of the preemptible instance. When the
price exceeds the threshold that you specify, the system sends a notification.
- Make preparations.
- Optional: Create a preemptible instance whose bidding mode is Use Automatic Bid (SpotAsPriceGo).
- Query the details of the preemptible instance.
For more information, see
View instance information. In this example, two preemptible instances are created, as described in the following
table. In subsequent steps, the O&M scripts for price monitoring are set based on
the details of the instances.
Instance name |
Region and zone |
Instance type |
Preemptible instance 1 |
Hangzhou Zone I |
ecs.c5.xlarge |
Preemptible instance 2 |
Hangzhou Zone K |
ecs.r6.xlarge |
- Create the
OOSServiceRole
role for OOS by using Resource Access Management (RAM). For more information, see
Grant RAM permissions to OOS. In the
Select Policy section of the Grant Permission page, select only the
AliyunECSReadOnlyAccess
policy.

- Add a DingTalk chatbot.
When you add a DingTalk chatbot, select Custom Keywords for Security Settings and enter Monitor
in the Custom Keywords field. In subsequent steps, OOS sends notifications by using
the webhook URL of the chatbot.
- Log on to the OOS console.
- In the left-side navigation pane, click Scheduled O&M.
- On the Scheduled O&M page, click Create.
- On the Create Scheduled O&M page, configure the parameters described in the following table and click Execute Now:
Parameter |
Description |
Set Scheduled Task |
Select Executed Periodically and configure the following parameters:
- Execution Frequency: Use the default settings. The task is executed once per hour.
Note The prices of preemptible instances change infrequently within a short period of time.
We recommend that you set the value to 1 hour.
- Time Zone for Periodic Execution: Specify the time zone based on your region. In this example, the default setting
is used.
- End Time for Period Execution: Specify the end time of the task based on your business requirements. In this example,
the default setting is used.
|
Select Template |
Enter ACS-ECS-AlarmWhenDiscountAndPriceExceedsThresholdInMultiZoneAndInstanceType in the search box. Then, select the template.
|
Configure Parameters |
Configure the following parameters based on the details of the created preemptible
instances:
- region: Select China (Hangzhou).
- zoneId: Select cn-hangzhou-i and cn-hangzhou-k.
- instanceType: Select ecs.c5.xlarge and ecs.r6.xlarge.
- taskType: Select a monitoring type based on your business requirements. Valid values:
- Discount: monitors the instance based on real-time discounts. For example, if the
pay-as-you-go price of an instance type is USD 0.400 per hour and the price of a preemptible
instance is USD 0.080 per hour, the discounted price for the preemptible instance
is 20% of the pay-as-you-go price. If you want to receive a notification when the
discounted price rises to higher than 25%, set taskType to Discount and set threshold
to 25 (75% off).
- Price: monitors the instance based on real-time prices. For example, assume that the
pay-as-you-go price of an instance type is USD 0.400 per hour and the price of a preemptible
instance is USD 0.080 per hour. If you want to receive a notification when the price
of the instance is higher than USD 0.090 per hour, set taskType to Price and set threshold
to 0.090.
- threshold: Set a threshold. Set this parameter based on the value of taskType.
- webhook: Specify the webhook URL of the DingTalk chatbot.
- rateControl: Use the default setting.
- Permissions: Select the
OOSServiceRole role.
|
Advanced |
Use the default settings. You can configure the parameters based on your business
requirements.
|
After the scheduled task is executed, you can view the state of the scheduled task
on the
Scheduled O&M page.

- Wait for the scheduled task to be executed or test the scheduled task.
- After the scheduled task is executed, the system monitors the bid price of the preemptible
instances in real time. If the price exceeds the specified threshold, a notification
is sent by using the DingTalk chatbot.
- In actual scenarios, the prices of preemptible instances do not fluctuate frequently
and the execution result of the scheduled task is difficult to be verified. You can
create a scheduled task and set the threshold to a value that triggers an alert. For
example, if the price of a preemptible instance is USD 0.080 per hour, the threshold
can be set to 0.040. Because the price of the preemptible instance remains higher
than the threshold, an alert is triggered when the scheduled task is executed, and
a notification is sent by using the DingTalk chatbot.