Edit

Share via


Azure Spot Virtual Machines for Virtual Machine Scale Sets

Using Azure Spot Virtual Machines (VMs) on scale sets allows you to take advantage of our unused capacity at a significant cost savings. At any point in time when Azure needs the capacity back, the Azure infrastructure evicts Azure Spot Virtual Machine instances. Therefore, Azure Spot Virtual Machine instances are great for workloads that can handle interruptions like batch processing jobs, dev/test environments, large compute workloads, and more.

The amount of available capacity can vary based on size, region, time of day, and more. When deploying Azure Spot Virtual Machine instances on scale sets, Azure allocates the instance only if there's capacity available, but there's no Service Level Agreement (SLA) for these instances. An Azure Spot Virtual Machine Scale Set is deployed in a single fault ___domain and offers no high availability guarantees.

Limitations

The following sizes aren't supported for Azure Spot Virtual Machines:

  • B-series
  • Promo versions of any size (like Dv2, NV, NC, H promo sizes)

Azure Spot Virtual Machine can be deployed to any region, except Microsoft Azure operated by 21Vianet.

The following offer types are currently supported:

  • Enterprise Agreement
  • Pay-as-you-go offer code (003P)
  • Sponsored (0036P and 0136P)
  • For Cloud Service Provider (CSP), see the Partner Center or contact your partner directly.

Pricing

Pricing for Azure Spot Virtual Machine instances is variable, based on region and SKU. For more information, see pricing for Linux and Windows.

With variable pricing, you have option to set a max price, in US dollars (USD), using up to five decimal places. For example, the value 0.98765would be a max price of $0.98765 USD per hour. If you set the max price to be -1, the instance won't be evicted based on price. The price for the instance will be the current price for Azure Spot Virtual Machine or the price for a standard instance, which ever is less, as long as there's capacity and quota available.

Eviction policy

When creating a scale set using Azure Spot Virtual Machines, you can set the eviction policy to Deallocate (default) or Delete.

The Deallocate policy moves your evicted instances to the stopped-deallocated state allowing you to redeploy evicted instances. However, there's no guarantee that the allocation will succeed. The deallocated VMs counts against your scale set instance quota and you're charged for your underlying disks.

If you would like your instances to be deleted when they're evicted, you can set the eviction policy to Delete. With the eviction policy set to delete, you can create new VMs by increasing the scale set instance count property. The evicted VMs are deleted together with their underlying disks, and therefore you aren't charged for the storage. You can also use the autoscaling feature of scale sets to automatically try to compensate for evicted VMs, however, there's no guarantee that the allocation succeeds. It's recommended you only use the autoscale feature on Azure Spot Virtual Machine Scale Sets when you set the eviction policy to delete to avoid the cost of your disks and hitting quota limits.

Users can opt in to receive in-VM notifications through Azure Scheduled Events. This notifies you if your VMs are being evicted and you have 30 seconds to finish any jobs and perform shutdown tasks prior to the eviction.

Eviction history

You can see historical pricing and eviction rates per size in a region in the portal. Select View pricing history and compare prices in nearby regions to see a table or graph of pricing for a specific size. The pricing and eviction rates in the following images are only examples.

Chart:

Screenshot of the region options with the difference in pricing and eviction rates as a chart.

Table:

Screenshot of the region options with the difference in pricing and eviction rates as a table.

Try & restore

This platform-level feature uses AI to automatically try to restore evicted Azure Spot Virtual Machine instances inside a scale set to maintain the target instance count.

Try & restore benefits:

  • Attempts to restore Azure Spot Virtual Machines evicted due to capacity.
  • Restored Spot VMs are expected to run for a longer duration with a lower probability of a capacity triggered eviction.
  • Improves the lifespan of an Azure Spot Virtual Machine, so workloads run for a longer duration.
  • Helps Virtual Machine Scale Sets to maintain the target count for Azure Spot Virtual Machines, similar to maintain target count feature that already exists for pay-as-you-go VMs.

Try & restore is disabled in scale sets that use Autoscale. The number of VMs in the scale set is driven by the autoscale rules.

Placement Groups

Placement group is a construct similar to an Azure availability set, with its own fault domains and upgrade domains. By default, a scale set consists of a single placement group with a maximum size of 100 VMs. If the scale set property called singlePlacementGroup is set to false, the scale set can be composed of multiple placement groups and has a range of 0-1,000 VMs.

Important

Unless you're using Infiniband for high-performance computing, it's strongly recommended to set the scale set property singlePlacementGroup to false to enable multiple placement groups for better scaling across the region or zone.

Deploying Azure Spot Virtual Machines in scale sets

To deploy Azure Spot Virtual Machines on scale sets, you can set the new Priority flag to Spot. All VMs in your scale set will be set to Spot. To create a scale set with Azure Spot Virtual Machines, use one of the following methods:

The process to create a scale set that uses Azure Spot Virtual Machines is the same as detailed in the getting started article. When you're deploying a scale set, you can choose to set the Spot flag, eviction type, eviction policy and if you want to try to restore instances: Create a scale set with Azure Spot Virtual Machines

Simulate an eviction

You can simulate an eviction of an Azure Spot Virtual Machine to test how well your application responds to a sudden eviction.

Replace the following with your information:

  • subscriptionId
  • resourceGroupName
  • vmName
POST https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Compute/virtualMachines/{vmName}/simulateEviction?api-version=2020-06-01

Response Code: 204 means the simulated eviction was successful.

For more information, see Testing a simulated eviction notification.

Next steps

Check out the Virtual Machine Scale Set pricing page for pricing details.