After you create a scaling group, you can apply an appropriate scaling policy to enhance resource utilization and cut costs. For additional savings, consider adding preemptible Elastic Compute Service (ECS) instances to the scaling group. This topic describes how to leverage preemptible instances for cost-effective cluster building.
Only scaling groups of the ECS type can contain preemptible instances.
What is a preemptible instance?
Preemptible instances are on-demand instances offering the same performance as regular ECS instances, but at a lower cost. Their prices fluctuate based on market supply and demand, potentially saving up to 90% compared to pay-as-you-go instances. Preemptible instances provide the following features:
Same performance: Preemptible instances and pay-as-you-go instances that use the same specifications offer identical performance, differing only in the billing method.
Bidding and reclamation: When creating preemptible instances, you can place a bid. Alibaba Cloud adjusts the market price based on supply and demand. If your bid is lower than the market price, the preemptilbe instances may be reclaimed. You can also enable automatic bidding, which enables the system to automatically adjust bids based on the market price, with the bid cap set at the price of pay-as-you-go instances.
Real-time bidding: Instance prices fluctuate in real time based on market supply and demand. If your bid exceeds the market price and resources are available, you can create preemptible instances.
Instance interruption and reclaimation: Preemptible instances can be interrupted and reclaimed if your bid is lower than the market price or if resources are insufficient.
Protection period: Preemptible instances have a protection period. For example, setting a 1 hour protection period for a preemptible instance prevents the instance from being recycled within the first hour after creation.
For more information about preemptible instances, see What are preemptible instances?
Summary: Preemptible instances in a scaling group offer cost savings with lower unit prices. However, this comes at the cost of stability, as preemptible instances may not always be available or created as expected.
Reduce costs by using preemptible instances
Preemptible instances offer cost savings for instance clusters in a scaling group. However, their instability requires careful consideration of potential impacts on cluster stability. Cluster stability can be assessed from the following aspects:
Scale-out stability: As the workload increases, new instances must be launched promptly and reliably to meet scale-out requirements.
Using preemptible instances may cause delays in instance creation due to market price fluctuations or insufficient inventory, impacting scale-out stability. However, you can configure mechanisms to enhance scale-out stability.
Instance stability: Instances should run stably without unexpected interruptions.
However, preemptible instances may be automatically reclaimed due to market price fluctuations or insufficient resource inventory. This requires the business system to quickly recover and seamlessly switch to available resources when preemptible instances are reclaimed.
After you evaluate the potential cost savings and impacts on cluster stability, the next step is to strike a balance that minimizes costs while ensuring service reliability and performance.
Design a solution that balances cost savings with cluster stability
The following ideas can help you design a solution that balances cost savings with cluster stability:
Set a reasonable bid strategy: To enhance the chances of securing preemptible instances and minimize interruptions, set a bid slightly higher than the market price but lower than the pay-as-you-go price.
Use multiple instance types: Adjust the ratio of preemptible instances to pay-as-you-go instances in your scaling group based on your business requirements to balance cost savings with cluster stability.
For example, you can set the ratio of pay-as-you-go instances to the minimum required for stable business running, and use preemptible instances to handle workload spikes and reduce costs.
The following figure illustrates how the stability and cost of a scaling group change with varying ratios of preemptible instances to pay-as-you-go instances. As the proportion of preemptible instances increases, costs decrease, but cluster stability also declines.
Improve cluster stability
In addition to designing a solution that stikes a balance cost savings with cluster stability, the following methods can further optimize your business:
| |
| |
| |
|
Example: Use preemptible instances to reduce costs in an existing scaling group
To add preemptible instances to an existing scaling group, perform the following steps:
Step 1: Configure vSwitches across multiple zones for the scaling group
Configuring vSwitches across multiple zones combines the resource inventories of the zones, which increases the availability of preemptible instances for the scaling group.
| |
| |
|
Step 2: Configure the cost optimization policy for the scaling group
| |
| |
|
Step 3: Modify the scaling configuration
This topic descirbes only how to modify the existing scaling configuration. You can also create a scaling group of the ECS type based on your business requirements.
| |
| |
| |
| |
| The figure shows that the Max Unit Price of Instance parameter is set to Enable Automatic Bid. |
|
Step 4: Trigger a scale-out operation to verify the configurations
After the configuration is complete, you can trigger a scale-out operation to verify the creation of preemptible instances in the scaling group. In this example, a scale-out operation is triggered by changing the expected number of instances.
Parameters
Percentage of Pay-as-you-go Instances: Set the value to 70%.
Minimum Pay-as-you-go Instances: Set the value to 2.
Expected Number of Instances: Change the value from 0 to 12.
Expected results
The scaling group contains nine pay-as-you-go instances and three preemptible instances.
Remarks
The minimum number of pay-as-you-go ECS instances specified by the Minimum Pay-as-you-go Instances parameter must be excluded when you calculate the percentage of.pay-as-you-go instances in the scaling group.
Therefore, the total number of pay-as-you-go instances is:
You can view the billing method of each instance in the ECS console.