Spot Instances – The hidden gem of AWS Ecosystem
Amazon has introduced a low-cost EC2 pricing option called ‘Spot Instances’ way back in 2009, where you could take advantage of unused EC2 capacity in the AWS cloud, at up to 90% discount compared to On-Demand prices.
In 2015 AWS introduced Spot Block & Spot Fleet, where you could launch Spot Blocks that will run continuously for a finite duration (1 to 6 hours), which is 30% to 45% less than On-Demand and you could launch Spot Fleet to meet the target capacity. It is a collection of Spot Instances, and optionally On-Demand Instances.
Despite the alluring discounts up to 90%, today’s AWS users/customers still fear using Spot Instances due to its interruption behavior.
The customers need to be aware of some of the newly introduced and enhanced features about spot Instances, such as
- Integration of Spot Instances with Autoscaling groups and several other AWS services such as AWS Batch, ECS, EMR, SageMaker, CloudFormation, Thinkbox, etc.
- Combine purchase options to optimize costs.
- Diversification & Spot flexibility.
- Select the best instance types with Spot Instance Advisor.
- Addressing Spot interruptions with STOP & RESUME workloads on EC2 Spot Instances.
- Workaround automation to address interruption notices of Spot Instances.
Two essential things customers should think primarily are
It is always prudent to review the Spot price history (90 day period) before deciding the ‘Maximum price’ when you request for Spot Instances.
You don’t have to bid for Spot Instances in the new pricing model, and you pay the Spot price that’s in effect for the current hour for the instances that you launch. It’s that simple. You can request Spot capacity just like you would request On-Demand capacity, without having to spend time analyzing market prices or setting a maximum bid price.
In the new model, the Spot prices are more predictable and is determined by supply and demand for Amazon EC2 spare capacity, not bid prices. You can find the price that’s in effect for the current hour in the EC2 console.
Login to https://console.aws.amazon.com/ec2/ Spot instances Pricing history
In the new model, you still have the option to further control costs by submitting a “Maximum price” that you are willing to pay in the console when you request for Spot Instances:
As “Selecting the best instance type “ is the core for all the above, we will explore this further:
As the overall availability improves by deploying your applications across different instance types, it is essential to focus on choosing the right Spot instance pool, which is the set of unused EC2 instances with the same instance type, operating system, Availability Zone, and network platform.
So far, we have been working with different types of instances for a variety of workloads. When it comes to the Spot instance pool, it makes sense to know about their ‘Frequency of Interruption’.
AWS has introduced ‘Spot Instance advisor,’ which provides the list of instance types and the Frequency of interruption’ in % along with the % of ‘Savings over On-Demand’.
As a customer, you should be able to determine your workload tolerance for interruption and the cost savings aspect.
Usually, we see the Frequency of interruption (the rate at which Spot has reclaimed capacity) in the below range.
- 5 to 10%
- 10 to 15%
- 15 to 20%
Based on the ‘Frequency of Interruption’, you can categorize them as
- Most Interrupted Instance Types
- Least Interrupted Instance Types
For better understanding, you can view the sample data (at the time of writing) as below which may vary with each region and for underlying OS (Linux/Windows)
It is recommend starting with instance types having lower frequency of being interrupted and adding more instance types as you improve your application’s flexibility and fault tolerance.