One of the biggest game changers to spot instances are spot fleets. I mentioned how you could save 60%-90% when you take advantage of spot instance pricing in: How Does Spot Pricing Work? Spot fleets is where things get even more interesting. With normal spot instance request, you place a bid for a specific instance type in one specific AZ and hope you get it. With spot fleets, you can request a variety of different instance types that meet your requirements. Additionally, you can spread your spot fleet bet across multiple AZs to increase the likelihood of getting your instance fulfilled. It’s like playing rollette and being able to bet a single chip on multiple numbers. Insanely cool! The method obviously dramatically increases the chances of you getting instances available at your spot bid price. Like I said, game changer.
Honestly, most of the time, it makes little difference which exact server you use if it has the enough of the right resources. Usually, that resource is CPU and RAM. For example, both the
m5.xlarge instances have
16GB of RAM and
4CPUs. So it makes sense to request for both instance types with a Spot Fleet request and let Spot Fleet will give you the lowest priced option. Generally, if the server has enough RAM and CPU, then your application should perform just as well.
Now there are some HPC, High Performance Computing, applications where the type of instances matters more. Here are a few examples: Genomics Processing, DNA Sequencing, Media Encoding/Transcoding, Computation Chemistry, Animation and Visual Effects Rendering, Financial Trading Analytics, Image Processing, Web Analytics, and Business Intelligence. In this cases, you scope the spot fleet request to the type of instance optimized for that resource.
For example, let’s say your Genomics Processing step has a high IO requirement. In that case, use I2 and I3 instance types for the request. There are still plenty of options within that instance family. HPC usually requires massive amounts of server resources and a large server farm. So it is even more important to use a variety of instances and lower your cost with spot.
Spot Fleet Weighting
With spot fleets, you can also apply a custom weighting to each instance type. Weighting tells the spot fleet request what total capacity we care about. As a simple example, say we would like a total capacity of 10GB of RAM and we select two instance types, one that has 2GB and one that has 4GB of RAM.
If we assign a weight to each instance that is equal to the amount of RAM, then we can tell the spot fleet to give us 10 units of capacity. Spot fleet then uses the weighting information to provision 10 units. It can be five 2GB instances or two 4GB and one 2GB instance. It does not matter. We still get a total of 10 units or 10GB of capacity.
Spot fleets work conservatively and will round up and slightly over provision if the instance types happen not perfectly to meet 10 units. For example, three 4GB instances result in 12 units. A more detailed explanation of spot fleet weighting is covered in this article: Spot Fleet Weighting and Pricing Explained.
Highly Available Architecture with Spot Fleets
Spot Fleets make it much easier to design a Highly Available fault-tolerant architecture with spot instances. With spot fleets, you can request a variety of servers for the spot fleet request. Additionally, you can have an on-demand AutoScaling cluster to serve supplementary capacity. You can fully switch over to on-demand when spot capacity is not available. The architecture takes advantage of the spot two-minute warning and AutoScaling lifecycle hooks to ensure that your systems remain up if the instance gets replaced. Here’s one example of an architecture that achieves just this: Spot Instance Highly Available Architecture.
Here’s a comparison chart with completely realistic a spot savings of 80%. Here’s also a more in-depth comparison of the difference in pricing: On-Demand vs Reserved vs Spot AWS EC2 Pricing Comparison
Spot fleets are the best thing since sliced bread. While it is possible to write the spot fleet logic yourself, there’s little point, AWS has once again done the hard work. It makes our lives much easier. We just have to learn how to leverage the spot fleet request fully. Doing so can save you 60%-90% of your AWS bill, no joke.