Preemptible instances are special pay-as-you-go instances. Compared with regular pay-as-you-go instances, preemptible instances provide discounts. Preemptible instances are designed to minimize the costs of Elastic Compute Service (ECS) instances in specific scenarios. 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 the bidding modes.
Comparison of bidding modes
The following table describes the bidding modes supported by preemptible instances.
Bidding mode | Description | Applicable scenario | Advantage | Disadvantage |
Bidding mode | Description | Applicable scenario | Advantage | Disadvantage |
Set Maximum Price (SpotWithPriceLimit) | You must specify a maximum hourly price to bid for an instance type. If the spot price (current market price per hour) of the instance type exceeds the specified maximum hourly price due to price fluctuations, a preemptible instance interruption event is triggered. | Business that has strict budget requirements. You cannot exceed the budget. | Strict cost control ensures that the instance type fees do not exceed the budget. | If the instance type price has sharp fluctuations, the probability of instance interruptions increases. |
Use Automatic Bid (SpotAsPriceGo) | In this mode, the preemptible instance is billed based on the spot price. | Business that does not have strict cost requirements. You want to reduce costs as much as possible. | This mode ensures that the preemptible instance is not interrupted due to price factors and reduces the probability of instance interruptions. | This mode makes costs difficult to control and may lead to cost overruns. |
Combination of Use Automatic Bid (SpotAsPriceGo) and CloudOps Orchestration Service (OOS) | In Use Automatic Bid (SpotAsPriceGo) mode, increases in instance type prices cannot be perceived. When the ACS-ECS-AlarmWhenDiscountAndPriceExceedsThresholdInMultiZoneAndInstanceType public template of OOS is used together with the Use Automatic Bid (SpotAsPriceGo) mode, 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. | This mode allows you to perceive increases in instance type prices and ensure that the preemptible instance runs in a stable manner. | Business that requires the ability to perceive price increases while improving instance stability. | OOS is required, which increases costs. |
The following table compares the bidding modes.
Bidding mode | Probability of instance interruptions due to price factors | Cost optimization | Cost controllability |
Bidding mode | Probability of instance interruptions due to price factors | Cost optimization | Cost controllability |
Set Maximum Price (SpotWithPriceLimit) | High | High | High |
Use Automatic Bid (SpotAsPriceGo) | Low | Relatively high | Relatively low |
Best practices for bidding modes
You can select a bidding mode based on your business requirements:
If you require strict control over your budget but do not require high instance stability, you can select Set Maximum Price (SpotWithPriceLimit).
If you require high instance stability but do not require strict control over your budget, you can select Use Automatic Bid (SpotAsPriceGo).
If you require both instance stability and cost control, you can use the Use Automatic Bid (SpotAsPriceGo) mode together with OOS.
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. To use the Use Automatic Bid (SpotAsPriceGo) mode together with OOS, perform the following steps:
Make preparations.
Create a preemptible instance and set the bidding mode to Use Automatic Bid (SpotAsPriceGo).
View 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 configured based on the details of the instances.
Instance name | Region and zone | Instance type |
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).
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, choose .
On the Scheduled O&M page, click Create.
On the Create Scheduled O&M Task page, configure the parameters that are described in the following table and click Create.
Parameter | Description |
Scheduled Task Type | Select Executed Periodically and configure the following parameters: Execution Period: Use the default setting. 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 configure the prices of preemptible instances to be checked at an interval of 1 hour. Time Zone: Specify a time zone based on your region. In this example, the default setting is used. End Time: 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 Template Parameters | Configure the following parameters based on the details of the created preemptible instances: RegionId: Select China (Hangzhou). ZoneId: Select Hangzhou Zone I and Hangzhou Zone K. InstanceType: Select ecs.c5.xlarge and ecs.r6.xlarge. TaskType: Configure this parameter based on your business requirements. Valid values: Discount: monitors real-time discounts. For example, if the pay-as-you-go price of an instance type is USD 0.400 per hour and the preemptible instance price of the instance type is USD 0.080 per hour, preemptible instances of the instance type offer a significant discount of 80% off the pay-as-you-go price. If you want to get notified when the discount for preemptible instances is higher than 75%, set TaskType to Discount and set Threshold to 25, which indicates a 75% discount. Price: monitors 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 preemptible instance price of the instance type is USD 0.080 per hour. If you want to get notified when the preemptible instance price exceeds USD 0.090 per hour, set TaskType to Price and set Threshold to 0.090.
Threshold: Specify a threshold. Configure this parameter based on the value of TaskType. Webhook: Specify the webhook URL of the DingTalk chatbot. RateControl: Use the default settings. Permissions: Select the OOSServiceRole role.
|
Execution Settings(Optional) | Use the default settings. You can also configure the parameters based on your business requirements. |
After the scheduled task is executed, you can view the status of the 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, you can set the threshold to 0.040. The price of the preemptible instance remains higher than the threshold. Therefore, an alert is triggered when the scheduled task is executed, and a notification is sent by using the DingTalk chatbot.
References
You can call the DescribeSpotAdvice operation to query information about preemptible instances in a region in the previous 30 days. The information includes the average release rate of preemptible instances and the percentage of the average preemptible instance price relative to the pay-as-you-go instance price.
Take the following CLI command as an example, in which the China (Hangzhou) region is used:
aliyun ecs DescribeSpotAdvice --region cn-hangzhou --RegionId 'cn-hangzhou'