What is Spot VM in Azure: Definition and Use Cases
Azure Spot VM is a virtual machine that uses unused Azure capacity at a discounted price. It can be evicted when Azure needs the capacity back, making it ideal for flexible, interruptible workloads.How It Works
Imagine you want to rent a car only when it's not being used by others. Azure Spot VMs work similarly by using leftover cloud capacity that is not currently in demand. This means you get a big discount, but your VM can be taken away if someone else needs that capacity.
When you create a Spot VM, you agree that Azure can stop your VM at any time if it needs the resources. This is called eviction. You can choose how Azure should handle eviction, like stopping or deleting the VM. This setup is perfect for jobs that can pause and resume without problems.
Example
This example shows how to create an Azure Spot VM using Azure CLI with eviction policy set to 'Deallocate'.
az vm create \ --resource-group myResourceGroup \ --name mySpotVM \ --image UbuntuLTS \ --size Standard_DS1_v2 \ --priority Spot \ --eviction-policy Deallocate \ --max-price -1 \ --admin-username azureuser \ --generate-ssh-keys
When to Use
Use Azure Spot VMs when you have workloads that can handle interruptions without losing progress. Examples include:
- Batch processing jobs like video rendering or data analysis
- Testing and development environments where uptime is not critical
- Stateless applications that can restart quickly
- Big data workloads that can checkpoint progress
Spot VMs help save costs significantly but are not suitable for critical applications that require guaranteed uptime.
Key Points
- Spot VMs use unused Azure capacity at a discount.
- They can be evicted anytime when Azure needs resources.
- Eviction policies include Deallocate or Delete.
- Best for flexible, interruptible workloads.
- Not recommended for critical or stateful applications.