Advertisement

Optimizing Cost on Azure with Spot Instances

By on
Read more about author Gilad David Maayan.

Azure Spot Virtual Machines (VMs) enable you to leverage unused Azure cloud capacity, offered at significantly low rates. Discounts vary but can get to 90% off the on-demand price. Spot VMs create a win-win situation – Azure gains customers for underutilized capacity, and customers get discounts that lower their cloud costs.

Azure Spot Instances: Pros and Cons

You can use Azure Spot VMs, also known as Azure Spot instances, to utilize Microsoft’s unused cloud capacity and save money. Microsoft offers discounts for its unused compute capacity. The available unused capacity differs according to factors such as the time of day and region. If Microsoft requires the capacity at any point, it can retrieve it from the VMs. 

Azure can evict Spot workloads from the cloud, and there are no availability guarantees of SLAs for Spot VMs. Spot VMs are thus suitable for workloads that can withstand interruptions, such as large compute jobs, batch processing jobs, DevTest environments, scalable stateless applications, and other non-critical workloads. 

The main drawback of using Spot instances is that there is no guarantee that the capacity will be available when you need it, especially during peak loads.

If you choose to work with Spot instances, you should be aware of the following:

  • Azure evicts VMs when its available capacity goes down or when your usage exceeds the maximum price.
  • Azure evicts Spot VMs if it requires the capacity for on-demand workloads.
  • Azure does not support Spot instances for promotional or B-series versions regardless of their sizes, such as Dv2, H, and cloud GPU instances from the NV and NC series.
  • You cannot convert Spot VMs into regular VMs (or vice versa), so if you want to replace one type of VM with another, you have to delete the old VM and connect the disk to a new one.
  • Azure does not automatically turn evicted or deallocated VMs back on when capacity becomes available, so you have to manually turn your Spot VMs back on.
  • You cannot create a Spot VM that exceeds the allowed capacity or price limits.

Azure Spot Pricing

The following is the pricing structure for Azure Spot VMs and Spot VM scale sets. There are several Azure price calculators available that can help you estimate your costs before and after the use of spot VMs.

Spot VM Pricing

Source: Pixabay

Azure VMs offer virtualization for various computing solutions and support servers such as Windows Server, Linux, SQL Server, IBM, and Oracle. The latest-generation virtual machines offer auto-scaling and load balancing at no extra cost. Discounts can reach 90% off pay-as-you-go computing costs, although they vary according to the VM type, region, and available compute capacity at the time of deployment.

Spot VMs are suitable for applications that can tolerate interruptions (Azure can notify you 30 seconds before evicting your application). If you prioritize lower costs and have flexible workloads that don’t need an SLA or specific timeframe, you should use Spot VMs.

Here is an example of the pricing for Spot VM instances:

  • General-purpose Av2: These are cost-effective VMs for small databases, microservices, DevTest environments, and applications or websites with low traffic. Pricing starts at $0.005/hour for Linux and Windows.
  • General-purpose Dv3: These are the latest-generation Intel Xeon-powered VMs, suitable for various workloads. Pricing starts at $0.0125/hour for Linux and $0.013 for Windows.
  • Memory-optimized Ev3: Pricing starts at $0.016/hour for Linux and Windows.
  • Compute-optimized Fsv2: These are the latest compute-optimized VMs, powered by Intel Xeon Platinum 8168 processors. Pricing starts at $0.0102/hour for Linux and $0.011 for Windows.

Spot VM Scale Set Pricing

VM scale sets (VMSS) allow you to build scalable applications easily by jointly deploying and managing groups of VMs. VM scale sets are based on the Azure Resource Manager deployment model and offer full Azure auto-scaling and load balancing capabilities. They support Windows and Linux (as well as custom images and extensions). 

There are two types of VMs you can use for scale sets:

  • Scale set VMs – allow you to create and manage identical virtual machines
  • Single VMs – allow you to add individual virtual machines when you create the scale set (for instance, to achieve high availability)

All Azure Windows and Linux VM sizes support scale sets. You pay only for the VMs you deploy and any additional underlying infrastructure resources you consume, such as networking and storage. The VMSS service does not incur incremental costs.

Here is an example of the pricing for Spot VM scale set instances:

  • General-purpose Av2: Pricing starts at $0.0184/hour for Linux and Windows.
  • General-purpose Dv3: Pricing starts at $0.0452/hour for Linux and Windows.
  • Memory-optimized Ev3: Pricing starts at $0.0356/hour for Linux and Windows.
  • Compute-optimized Fsv2: Pricing starts at $0.0288/hour for Linux and Windows.

Conclusion

In this article, I explained the basics of Azure Spot instances, also known as Spot VMs, and their pros and cons:

  • The obvious advantage is that Spot VMs grant discounts of up to 90% compared to on-demand rates.
  • Disadvantages include lower reliability, unpredictable availability of Spot VMs, and lack of support for some instance sizes (e.g. Dv2, NV, and NC). 

In general, the Azure Spot VM offering is less mature and provides less sophisticated automation features than the market leader, Amazon. However, Azure is quickly catching up and offers a robust solution suitable for production applications. Carefully consider the pros and cons of Azure VMs and see if the lower cost compensates you for the added complexity and risk. 

I hope this will be of help as you adopt advanced cost optimization strategies in the Azure cloud.

Leave a Reply