All Products
Search
Document Center

Elastic Compute Service:Select a bidding mode for a preemptible instance

Last Updated:Dec 28, 2023

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 CloudOps 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

Combination of Use Automatic Bid (SpotAsPriceGo) and OOS

Low

High

Slightly high

High

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.

  1. Make preparations.

    1. Optional: Create a preemptible instance whose bidding mode is Use Automatic Bid (SpotAsPriceGo).

      For more information, see Create a preemptible instance. If you have created a preemptible instance, skip this step.

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

    3. 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. Select Policy

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

  2. Log on to the OOS console.

  3. In the left-side navigation pane, choose Automated O&M > Scheduled O&M.

  4. On the Scheduled O&M page, click Create.

  5. On the Create Scheduled O&M Task page, configure the parameters described in the following table and click Create:

    Parameter

    Section

    Set Scheduled Task

    Select Executed Periodically and configure the following parameters:

    • Execution Frequency: 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 for Periodic Execution: Specify a 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 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: Set 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. Set 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.

    Advanced

    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. Scheduled O&M

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