In this article, we will see what are Spot Virtual Machines and how can one save costs using these virtual machines.
Azure Spot Virtual Machines:
Azure spot virtual machines are the VMs that are unused at the time and one can take advantage of Azure’s this spare compute capacity for their needs at a very low cost as compared to the Pay-As-You-Go pricing model. Azure has enough cloud servers in their inventory and that inventory doesn’t get used enough by customers, so Azure rent them to customers as a spot Virtual Machine. If demand for virtual machines or compute capacity increases from on-demand (pay-as-you-go) customers then Azure can take back their servers by just giving a short warning. Therefore, Azure spot virtual machines are not recommended to work that needs fewer interruptions.
The amount of spare server computes capacity of Azure can vary based on various factors like region for VM deployment, size of VM, time of day, etc. When there is capacity available the Azure will allocate Virtual Machine. But for these VMs there is no Service Level Agreement(SLA). SLA is basically a commitment that Azure provides to their customers for servers’ uptime and connectivity. Azure spot virtual machines are a great solution for the workloads that can handle interruptions. According to Azure, up to 90% of the cost can be saved using spot VMs than the pay-as-you-go pricing model.
Advantages of using Spot Virtual Machine:
- By using spot virtual machines, you can save up to 90% of pay-as-you-go prices.
- Spot VM can be used with low-priority workloads and can be saved a lot of costs.
- You can set the maximum price for spot virtual machines up to what you want to pay.
Limitations for Spot Virtual Machines:
- B series VM size is not supported for spot VMs.
- Promotional versions of VM sizes like Dv2, NC, H are also not supported.
- Azure spot virtual can be deployed to any region in the world except the china 12Vianet region.
- There is no SLA offered for spot virtual machines
- Deallocation or deletion of spot virtual machine occurs within a very short interval of time( 30 seconds)
Terms to consider before the creation of Spot Virtual Machines:
Azure provides two eviction methods for VMs based on capacity and max price you set.
- Capacity only: In this azure will evict virtual machine when needs capacity back for pay-as-you-go workloads. Means maximum price for the spot VM is the current price of a regular Virtual machine
- Price or capacity: In this customer has the flexibility to set the max price they are willing to pay for the VM. If spot price goes above the max price or Azure needs their capacity back for pay-as-you-go workloads then the virtual machines will be evicted.
Here Azure provides customers to choose what will happen to their virtual machine after eviction. We can set an eviction policy to delete or deallocate. By default Stop/Deallocate is selected.
- Stop/Deallocate: After the eviction of VM Stop/Deallocate policy moves that spot VM to deallocated state. You can then reallocate that VM or can have access to the disks. But you will be charged for the storage of the disks of that virtual machine.
- Delete: After the eviction, the virtual machine will be deleted along with disks associated with it. So you will no longer be charged for that virtual machine.
The maximum price you want to pay per hour (Option valid only for Price or capacity selection ):
- If the max price is greater than or equal to the current price of a regular VM then spot VM will be allocated when capacity is available. If the max price is less than the current price of a regular VM then you will receive an error message.
- The value must not be empty and the price must be greater than the hardware cost that Azure holds, in this case, the minimum price must be $0.02638. This minimum price changes with the size and location of the Virtual Machine.
- If we set the max price for VM to -1 then the current price for a regular VM is the max price for a spot VM. This max price goes to the standard price of VM.
- If we want to change the max price again then we can first deallocate the spot VM and then we can change the max price again.
Creating a Spot Virtual Machine:
Follow the below steps to create a spot virtual machine:
Step 1: Open the Azure portal and search for “virtual machines” in the left bar or in global search.
Step 2: In the Virtual Machine section, click for create a virtual machine.
Step 3: Then check for Azure spot instance, you can see more options now.
Step 4: Then check for other options like Disks, networking, management, etc. After everything, you will see the following window. Then click Review + create.
After your spot virtual machine is successfully deployed. If you want to change the maximum price you want to pay for spot instances then you have to first deallocate VM first, then you can set price and allocate VM again.