Optimize cost with Virtual Machine Scale Set Spot Mix
Azure Virtual Machine Scale Sets (VMSS) are a way to create and manage a group of identical VMs that can automatically scale up or down based on demand. VMSS can use Azure Spot Virtual Machines (Spot VMs) to reduce costs and optimize resource utilization. Spot VMs are unused Azure compute capacity that is available at a significant discount compared to standard (on-demand) VMs.
However, Spot VMs have some limitations and trade-offs. They can be evicted at any time when Azure needs the capacity back, and they may not be available in all regions or sizes. To mitigate these risks, you can use a new feature called Spot Priority Mix for VMSS. This feature allows you to specify a percentage distribution of standard and Spot VMs in your scale set, so that you can balance high availability and cost savings.
Let’s see how we can use this feature using a demo.
I will start by creating a normal Virtual Machine Scale Set using the portal and I will select the orchestration mode as Flexible to be able to use Spot instances.
To be able to use Spot instances also, we need to check the Run with Azure Spot discount option. And I will select the Standard_D4s_v3 AS my VM size.
In the Spot tab, I will have to specify the normal options for a spot instance like the eviction type whether its based on capacity or the maximum price I’m willing to pay, and eviction policy whether I need to keep the evicted VM in case I can redeploy it again.
Next, the most important screen where I specify the percentage of standard (uninterruptible) VMs Vs. Spot Instances in my scale set. In this example, I decided to have a minimum of 10 standard (uninterruptible) VMs and 70:30 ratio of standard (uninterruptible):Spot Instances.
Finally, I will specify that the minimum number of instances in this scale set should be 10 and I will use a manual scaling option for the sake of this demo.
So to summarize, we have a VMSS with the following settings:
- Minimum of 10 VMs in this scale set.
- The scale set needs to have at anytime at least 10 standard (uninterruptible) VMs.
- The ratio for standard (uninterruptible) VMs and Spot Instances at any point should be 70% to 30%.
After deploying this scale set, we can see that we don’t have any Spot Instances deployed since we started with 10 VMs and we need to have a minimum of 10 standard (uninterruptible) VMs.
If we scale up the VMSS to 20 instances, we start to see that we are getting 3 Spot Instances and 17 as standard (uninterruptible) VMs. This is due to adding 10 instances to the current scale set, we have 10 that need to be standard (uninterruptible) and the other 10 should be 70:30 standard (uninterruptible):Spot Instances.
This allows us to balance high availability and cost when creating large Virtual Machine Scale Sets. If we take a look at the cost of the VM size we selected ‘Standard_D4s_v3’ , we can see that with Spot Instances we save around 39% (166.59$ Vs. 274.48$) compared to the Pay-as-you-go price.
You May Also Like
The cloud gives you infinite scale and scalability, and with this …
Remember in the old days when using group policy on-premises, you had …
The Azure Monitor agent (AMA) is the agent replacing all of Azure …