Running containers on spot infrastructure

Michael Wittig – 14 Apr 2021

Running workloads on spot infrastructure is significantly cheaper. You can reduce your bill by 50% or more. Keep in mind that spot workloads can be terminated at any time. If you are lucky, you will be noticed 2 minutes upfront to shut down gracefully. In this blog post, I compare the options that AWS provides to run container workloads on spot infrastructure.

Reduce your AWS bill

Options

After you select your scheduler EKS or ECS, you can choose from the following options to run your containers on spot:

  • ECS
    • Fargate
    • Self-managed EC2
  • EKS
    • Managed node groups
    • Self-managed EC2

Self-managed EC2 benefits from all the spot features that are available for EC2 instances. The downside is the self-managed part: You are responsible for scaling, patching, monitoring, and so on. Therefore, I recommend using the option highlighted in bold. If your scheduler of choice is ECS, I recommend running your workload on Fargate Spot. All you need to do is to turn a single knob. If you prefer EKS, managed node groups are the way to go with native support for spot.

EKS Fargate does not support spot at this time!

cloudonaut plus

Staying ahead of the game with Amazon Web Services (AWS) is a challenge. Our weekly videos and online events provide independent insights into the world of cloud. Subscribe to cloudonaut plus to get access to our exclusive videos and online events.

Subscribe now!

Fallback to on-demand?

How can we fall back to on-demand capacity if the spot capacity was terminated? My usual answer is this: Spot capacity is cheap because AWS can, at any time, decide to take it away from you. If you can not accept that spot capacity can be terminated at any time, it might not be a good fit for your workload!

But wouldn’t it be nice if we could benefit from the spot savings for most of the time but with a safety net of on-demand capacity? If you use ECS, there is no native way of implementing a fallback. If you use EKS, kubernetes and the Autoscaler can do the job. The following video goes into details and includes demos:

  • Spot Refresher
  • Demo: ECS Fargate
  • Pitfall: Handle interruption notice
  • Pitfall: Fallback to on-demand
  • Demo: EKS managed node group

Already a cloudonaut plus subscriber? Watch the full video and join the discussion.

Summary

AWS supports many options to run containers on spot infrastructure to optimize your AWS bill. The clear winners in terms of ease of use are ECS Fargate and EKS managed node groups. I was able to switch from on-demand to spot using ECS Fargate in a couple of minutes. Since then, I enjoy the lower AWS bill :)

Michael Wittig

Michael Wittig

I'm an independent consultant, technical writer, and programming founder. All these activities have to do with AWS. I'm writing this blog and all other projects together with my brother Andreas.

In 2009, we joined the same company as software developers. Three years later, we were looking for a way to deploy our software—an online banking platform—in an agile way. We got excited about the possibilities in the cloud and the DevOps movement. It’s no wonder we ended up migrating the whole infrastructure of Tullius Walden Bank to AWS. This was a first in the finance industry, at least in Germany! Since 2015, we have accelerated the cloud journeys of startups, mid-sized companies, and enterprises. We have penned books like Amazon Web Services in Action and Rapid Docker on AWS, we regularly update our blog, and we are contributing to the Open Source community. Besides running a 2-headed consultancy, we are entrepreneurs building Software-as-a-Service products.

We are available for projects.

You can contact me via Email, Twitter, and LinkedIn.

Briefcase icon
Hire me