Spot VMs in Azure

 Microsoft-Azure, Office 365
Mar 15 2020

Spot VMs in Azure:

Microsoft announces Spot VMs in Azure, using this feature customers can take benefit of Azure’s unused capacity at lowest cost. Spot VMs replaces the Low-priority VMs. Azure Spot VMs can be used for testing purposes, batch processing jobs, large compute workloads, and more. Don’t get confused about this feature, it’s not a big deal, we will discuss this feature in this blog



To clear about this feature, we are going to talk over some of the topics given below.

  1. What is Spot VMs in Azure?
  2. What is the Difference between regular VMs and Spot VMs?
  3. How to create Azure Spot Vms?
    1. 3.1 what is Capacity only type?
    2. 3.2 What is Price or capacity type?
  4. When our VMs get evicted?
    1. 4.1VMs eviction:
    2. 4.2How to safeguard our VM eviction based on pricing?
    3. 4.3When our VM get deployed/Vm is not deployed?
  5. Restrictions:

1.What is Spot VMs in Azure?

Microsoft announced a Spot VMs mainly for utilizing their unused capacity with the lowest amount than pay as you go. The amount of available capacity can vary depends on region, size, time and more. But one thing we need to remember, Azure will evict our VMs at any time.

2. What is the Difference between regular VMs and Spot VMs?

Both are not much distinct, but the difference is Spot VMs have no SLA (Service Level Agreement, its commitment between service providers and users), and our VMs will get evicted at any time.

3. How to create this Azure Spot VMs?

When creating VM in the Azure portal you can view the Azure Spot instance option, if toggle this option to yes, you can see two types of Eviction.

  • Capacity only
  • Price or capacity


3.1: what is Capacity only type?

In this Capacity only type your max price is set to pay as you go rate, and Microsoft will evict our VM when they need the capacity for pay as you go workloads.



3.2: What is Price or capacity type?

In this Price or capacity type, you have a good option to decide the Max price that you want to pay per hour. If you decide you want to spend only a fixed amount and don’t want to spend more for testing purpose, in this case you can select Price or capacity type.



Azure recommends to select the max price, and also having chance for getting increase in cost of the instance, in such a situation our VMs get evicted. And Azure will also evict when Azure needs a capacity for pay as you go workloads.



4. When our VMs get evicted?

Azure will evict our VMs when our capacity or price is met. When Azure evict our VM it will send a notification through Azure Scheduled Events that says “your VM are being evicted and you have 30 seconds to save your positions and complete shutdown tasks”. Then after 30 seconds, VM moved to deallocate state, which means VM gets evicted and then we need to redeploy the evicted VM.

So, it’s time to see when our VM gets evicted, and how we can save our VM without eviction, let’s talk over the scenario.

4.1: VMs eviction:

Our VMs gets evicted for two reason

  • If Azure needs the capacity back, then Azure evict our VMs.
  • If the cost of the Spot VM gets increased when compared to the price you set during deployment.

For example, look at the below image. During deployment, I select the max price which is Canada central ($0.02220), but currently, the price of the VM gets increased than the max price we set early, in such a state our VM gets evicted.



4.2: How to safeguard our VM eviction based on pricing:

If you set the maximum price to -1, then our VM will not get evicted for pricing reason, because -1 is considered as a current price up to price for standard VM.

4.3: When our VM get deployed/Vm is not deployed:

When our VM get deployed When our VM is not deployed
Selecting the Max price greater than the current price. Setting Max price, which is lesser than the current price, it shows error, that max price needs to be greater than the current price.
Restarting the evicted VM: Selecting the Max price greater than the current price. Restarting the evicted VM: Setting the Max price, that is lesser than the current price, it shows an error, that the max price needs to be greater than the current price

And two more scenario we meet:

  • After the eviction, if the price for the VM getting back to the current price, which is lesser than our max price: Now the VM will not restart automatically, we need to restart by hand. And the charge is based on the current price.
  • If you want to change the Max price, then you need to deallocate the VM and fix the new price and need to update VM by yourself.

5.Restrictions:

  1. Spot VM will not be supported in B-series, Promo version of any size.
  2. Spot VM will not be supported In Microsoft Azure China 21Vianet.
  3. Spot VM does not use ephemeral OS disks.