How to save BIG on Azure with Spot Instances

Nov 16, 2023

How to save BIG on Azure with Spot Instances Banner

I have been working with Azure for a long time… So I am ashamed to say that I did not know about Spot instances until I saw an announcement this summer about them being available for Azure Container Instances (ACI). Now, I use them in many scenarios and save a ton of money for myself and my clients.

What are Spot Instances?

First things first, Azure Spot Instances are a way to get cheap and scalable computing power on the Azure cloud. They run on unused Azure capacity and can be up to 90% cheaper than the regular price. However, they can also be evicted at any time if Azure needs the capacity back or if the price goes above your limit. So, they are best for workloads that can handle interruptions, like testing, batch processing, or analytics.

Currently, Spot Instances are being offered on Azure Virtual Machines and Azure Container Instances (ACIs are on public preview and only available in West Europe, East US, and West US2).

How does it work?

When you create your instance, you will have the option to “Run with Azure Spot discount”. The image below shows an example of creating a VM, but a similar option appears when creating ACIs:

Spot Instances Setup

Once you select your Discount, you can decide the Eviction Type and the Eviction Policy, according to your needs. As a reminder, Spot instances are operating on excess capacity; if resources are needed by Azure, you can and will get evicted. So, these should only be used on non-critical workloads, or on workloads where interruptions are needed.

Benefit$$$?

The main benefit is cost. You can run with tons of computing power, paying only a fraction of the cost. Imagine, for example, a rendering job that runs sporadically but requires powerful machines; you can use Spot Instances to get the job done, at a low cost, and then stop the machine yourself or let it be deallocated. You can use Spot Advisor to calculate your potential savings, but in most cases, the savings are simply amazing:

Sample Savings for Spot VMS
Sample Savings for Spot VMS

Besides the possibility of getting evicted, Spot Instances are basically identical to the regular service:

  • Fast and reliable. They use the latest hardware and software technologies to deliver high performance and availability.
  • Secure and compliant. They are protected by multiple layers of security, including encryption, firewalls, and identity management.
  • Scalable and flexible. You can easily scale up or down depending on your workload and demand.
  • Cost-effective and convenient. They have a pay-as-you-go pricing model, which means you only pay for what you use.You can also save money by using reserved instances, spot instances, or hybrid benefit options.
  • Plus, you can access your virtual machines from anywhere using the Azure portal, CLI, or SDK.

Where have I used them?

I am currently using a Spot VM Machine to run a client application that we are modernizing. The application is running as a reference for our development team, so it is not critical, however, it does require a bit of compute power. Having a Spot Instance just made sense, we have been running it for a month or so and have not been evicted once.

We are also using ACI. We have a nightly process that manages images, it requires a fair bit of computing power, but in the right environment should only run for an hour or so. The ACI running our image is started/stopped programmatically, and because it knows how to stop/resume its process, we are not very concerned about being evicted in the middle of a run.

I am sure there are many other scenarios where this can be used, now that I know about them, I keep my eyes open to cost savings 😄

Is worth saying again: Really think about the scenario before you jump into Spot Instances, no critical workloads should be running on them.