At any one time Microsoft can have huge amounts of unused computing capacity in their Azure global data centres. In order to monetize this they offer customers ‘Spot’ virtual machines. Spot Virtual machines are those offered to customers at significant cost discount (sometimes up to 90%) but which have no high availability SLAs and from which the customer can be evicted (VM deallocated) as soon as Microsoft needs the capacity back for higher paying customers.
Due to the lack of high availability SLAs spot machines are not suitable for many scenarios. According to Microsoft…
Assuming you have workloads which can deal with and recover from occasional expected downtime the two big considerations when choosing to use spot VMs or not are..
Price Discount – how much are you going to save compared to regular VMs of the same spec in the same region. Does the saving % justify the hassle of potential eviction? With discounts of 60%-90% the hassle is almost certainly justified. Note the spot price is not fixed and can change depending on demand etc.
Eviction Rate – how often is the machine going to be deallocated. If your getting kicked out of the VM so often sure you won’t be charged but neither will your workloads complete.
The ideal combination is obviously high % discount and low eviction rate. Pricing information has been available in the portal for a while (and more recently the pricing API) but eviction rate information is only available (in preview) since October 2020.
Viewing spot virtual machine eviction rates in Azure portal
First open up the ‘Create a virtual machine’ page and select the checkbox next to ‘Azure Spot Instance’.
In the instance above you can see I’m creating a DS2_v2 (general purpose spec) Ubuntu Linux machine in the East US region. The two options to see eviction rates are highlighted above and are ‘See all sizes’ and ‘View pricing history and compare prices in nearby regions’
Eviction rates for all sizes for an operating system and region combination
The see all sizes option shows you pricing and eviction rates for all sizes available for your chosen region (East US) and operating system (Ubuntu) combination. Click on the image below for a larger view.
You can see eviction rate information highlighted in red. I’m not sure what data range the eviction rate covers but the original post on the Azure updates page from October 2020 mentions the rate applies to the last 28 days. And in the case of the VM I selected above (DS2_v2) we have an eviction rate of 0-5% and savings of 78% (current estimated discount, remember spot rates are not fixed) which is great.
By default the ‘See all sizes’ page is ‘Grouped by Series’ but in the screenshot I’ve changed that to ‘No Grouping’ via the top right hand side dropdown. This way I can sort by eviction rates.
Combining eviction rate sort with the min ram and vCPUs filters at the top of the page gives me an easy way to find suitable spot VMs which have the most discount with the least amount of interruption.
From trying a few combinations of operating systems and regions I’m not really seeing any pattern to which VM sizes/types get evicted more or less than others. For example machines which have higher specs aren’t always the ones that get evicted most.
Comparing eviction rates (and prices) across nearby regions
In the above ‘See all sizes’ view there is no comparison with other regions. Comparing rates across nearby regions is useful as we know various Azure services can differ in price from region to region depending on things like demand and infrastructure costs.
To compare eviction rates in regions nearby we can click ‘View pricing history and compare prices in nearby regions’ and a view similar to below (click on the image for a larger view) will open.
We can see the eviction rate for both East US and Canada Central is 0-5%, while East US 2 is significantly higher at 15-20%.
Both East US and East US 2 are based in Virginia so why the big difference in eviction rate? Well judging from the below chart (credit to azureprice.net/Region), on average VMs are cheaper in East US 2. Its just speculation but this might mean East US 2 is more popular and has less unused capacity meaning more evictions and thus lower spot rate.
We can see from the three regions shown above that while Canada Central also has a low eviction rate of 0-5% to match East US it is significantly cheaper meaning it might be a viable spot VM region for development machines (for example) for a team based somewhere in East coast USA (as an alternative to East US / East US 2).
From an architectural point of view yes ideally you’d keep your Azure resources in the same region as whatever/whoever will be using them for latency reasons but everything is a trade off. In this case the teams development boxes will be 1) a lot cheaper and 2) experience less interruptions but might have extra latency. Going by the December 2020 region – region latency figures below latency between East US/East US 2 and Canada Central is around 26-30ms which is still pretty fast.
Looking back at the portal below.. interestingly from a historical pricing point of view we can see that spot prices were highest in East US and East US 2 on November 30th which was Cyber Monday.
Ecommerce shops would have have been a lot busier around this time and thus CPU demand would increase hence higher spot prices. It’s quite possible that eviction rates on Cyber Monday increased in line with spot prices but we can’t know that for sure.
A great future addition to this page would be if we could get a line chart plotting historical eviction rate too so we could see the direct relationship between regions, dates (and possibly times) and eviction rates. Its likely eviction rates are lower during the night so this information could help reduce costs further.
Spot VMs are relatively new on Azure having only been released into GA (general availability) in May 2020 but there’s huge savings to be made if you have appropriate workloads. Now that eviction rates are available on the portal its easier to find high discount/low interruption VMs. Depending on your workload consider hosting your spot VMs in regions other than those closest and just like normal VMs don’t forget to turn your spot machines off when not using them to reduce costs further.