Azure Spot Virtual Machines

What is a Spot Instance?

“Azure Spot offers unused Azure capacity at a discounted rate versus pay as you go prices. Workloads should be tolerant to infrastructure loss as Azure may recall capacity for pay as you go workloads.”

Similar to Spot Instances in Amazon Web Services (AWS), Azure allows you to pay a reduced for virtual machines that would otherwise leave hardware unused. This provides an advantage to the platform operator and the user by giving capacity that would have went unused to be used at a reduced rate. I enjoy this feature as it allows me to use GPU Sku instances at a lower price, I don’t want to pay retail pricing for dev/test.

Creating a Spot VM

Creating a Spot VM is very easy, as it’s simply a toggle during your initial setup of a virtual machine within the portal.

Start by creating a new virtual machine, however you choose to get there works. I prefer to navigate to Virtual Machines > and select +Add

While creating the VM, you’ll see this section below after you toggle Yes under ‘Azure Spot Instance’. Your choices are: Capacity Only and Price or Capacity

  • Capacity only: evict virtual machine when Azure needs the capacity for pay as you go workloads. Your max price is set to the pay as you go rate.
  • Price or capacity: choose a max price and Azure will evict your virtual machine when the cost of the instance is greater than your max price or when Azure needs the capacity for pay as you go workloads.

In this write up, I’ll create a GPU Sku NV6 VM to show some cost benefits for using this. We’ll pretend I’m using a VM that’s preconfigured to allow eviction on short notice, but also to start services automatically if I fall back into the criteria of my Spot Instance demand. When a VM is evicted, it’s placed in a deallocated state by default unless stated to delete.

As you can see below, estimated savings of running an NV6 VM comes out to ~$0.18/hr with an 87% cost savings over Pay-As-You-Go in East US. This VM type was just for example, but the savings are substantial across the board, depending on which VM type you intend to use.

There are limitations for using Spot Pricing:

  • B-series
  • Promo versions of any size (like Dv2, NV, NC, H promo sizes)
    In my example, I used an NV non-promo Sku, which is why I was able to select spot pricing.

Conclusion

As you can see, spot pricing gave me the ability to run a GPU equipped VM with 6 vCPUs and 56 GB of Memory. Although this isn’t a general purpose VM type, it’s comparable to running a D2s_v3 in terms of pricing.

This should not be used for production or any live application, as these rates (unless your threshold is higher than the bare minimum like mine was in this example. You may see better consistency results with a higher pricing threshold, but there is no guarantee of capacity with spot instances.

Thank you!

More Information

https://azure.microsoft.com/en-us/pricing/spot/
Featured Image courtesy of Microsoft

Advertisement

Leave a Reply

Your email address will not be published. Required fields are marked *