AWS Spot Instances – Why, When, and How to Use Them

Over the years, I have worked in IT for decades. There has been one rule that IT pros have followed for decades: Keep everything running at all costs. If you can do this, you will make everyone happy, and your life will be great.
Anyone who has worked in IT over a long time knows that this goal is not always achievable. It also ignores an important truth: While it is possible to make workloads highly accessible, it comes with a price.
Because some workloads will be more important than others it is impossible to justify high availability. It is unlikely that it makes sense to invest in dev/test workload protection against outages as you would spend on protecting your payroll application from downtime.
Most organizations have both mission-critical workloads and less important workloads. Amazon EC2 Spot Instances can help reduce the cost of less-important workloads.
Spot instances are identical with a regular EC2 instance except for two things. Spot instances use a different billing system than regular EC2 instances. Spot instances can be interrupted. Spot instances should not be used to run mission-critical workloads. Spot instances are useful for dev/test workloads or for adding computing power to large-scale data analysis projects.
This raises the question as to why spot instances are susceptible to interruption. To answer this question, you need to know a bit more about spot instances and how the spot invoice model works.
Understanding spot instances requires that you look at how cloud service providers like Amazon Web Services (AWS), operate. Cloud service providers invest in hardware resources, then release those resources to subscribers (often on an hourly basis). This business model has a problem. There are likely to be resources that are not being used at any given moment. These resources are hardware capacity that AWS paid for, but they are not being used and not making AWS any money.
AWS does not allow these computing resources to be wasted. Instead, they offer them at a significantly discounted rate. This means that if someone requires those resources to run a normal EC2 instance of EC2, that instance will have priority over spot instances that are using the resources at a discounted price. Spot instances will be terminated if they are not required.
This is the basic idea behind spot instances. However, spot billing is a bit more complex than I have described. In actuality, spot instances do not use flat-rate billing. AWS calculates spot instances’ costs based on demand and supply. Spot instance costs rise as compute resources become more in demand. Spot resource costs decrease as demand falls.
Spot resources can be used by anyone who tells AWS how much they will pay per hour. Spot instances will continue running until the resource’s cost exceeds or meets the agreed-upon price. Subscribers are free to terminate or stop spot instances at any time.
It is simple to request a spot instance. Open the AWS console, then go to the EC2 dashboard. Next, locate the Instances section and click on Spot Requests. Next, click on the Request Spot Instances link, as shown in Figure 1.
[Click on the image to see a larger view.] Figure 1: This shows how to request a spot instance. After submitting your request, you will be taken directly to Figure