You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
title: Run Batch workloads on cost-effective Spot VMs
3
3
description: Learn how to provision Spot VMs to reduce the cost of Azure Batch workloads.
4
4
ms.topic: how-to
5
-
ms.date: 04/06/2023
5
+
ms.date: 04/11/2023
6
6
ms.custom: seodec18
7
7
---
8
8
9
-
# Use Spot VMs with Batch
9
+
# Use Spot VMs with Batch workloads
10
10
11
11
Azure Batch offers Spot virtual machines (VMs) to reduce the cost of Batch workloads. Spot VMs make new types of Batch workloads possible by enabling a large amount of compute power to be used for a low cost.
12
12
13
13
Spot VMs take advantage of surplus capacity in Azure. When you specify Spot VMs in your pools, Azure Batch can use this surplus, when available.
14
14
15
-
The tradeoff for using Spot VMs is that those VMs may not always be available to be allocated, or may be preempted at any time, depending on available capacity. For this reason, Spot VMs are most suitable for batch and asynchronous processing workloads where the job completion time is flexible and the work is distributed across many VMs.
15
+
The tradeoff for using Spot VMs is that those VMs might not always be available, or they might get preempted at any time, depending on available capacity. For this reason, Spot VMs are most suitable for batch and asynchronous processing workloads where the job completion time is flexible and the work is distributed across many VMs.
16
16
17
-
Spot VMs are offered at a reduced price compared with dedicated VMs. For pricing details, see [Batch Pricing](https://azure.microsoft.com/pricing/details/batch/).
17
+
Spot VMs are offered at a reduced price compared with dedicated VMs. To learn more about pricing, see [Batch pricing](https://azure.microsoft.com/pricing/details/batch/).
18
18
19
19
## Differences between Spot and low-priority VMs
20
20
21
-
Batch offers two types of low-cost pre-emptible VMs:
21
+
Batch offers two types of low-cost preemptible VMs:
22
22
23
23
-[Spot VMs](../virtual-machines/spot-vms.md), a modern Azure-wide offering also available as single-instance VMs or Virtual Machine Scale Sets.
24
24
- Low-priority VMs, a legacy offering only available through Azure Batch.
25
25
26
-
The type of node you get depends on your Batch account's pool allocation mode, which is settable during account creation. Batch accounts that use the **user subscription** pool allocation mode always get Spot VMs. Batch accounts that use the **Batch managed** pool allocation mode always get low-priority VMs.
26
+
The type of node you get depends on your Batch account's pool allocation mode, which can be set during account creation. Batch accounts that use the **user subscription** pool allocation mode always get Spot VMs. Batch accounts that use the **Batch managed** pool allocation mode always get low-priority VMs.
27
27
28
28
> [!WARNING]
29
-
> Support for low-priority VMs will be retired after **30 September 2025**. Please
30
-
> [migrate to using Spot VMs in Batch](low-priority-vms-retirement-migration-guide.md) before then.
29
+
> Low-priority VMs will be retired after **30 September 2025**. Please [migrate to Spot VMs in Batch](low-priority-vms-retirement-migration-guide.md) before then.
31
30
32
31
Azure Spot VMs and Batch low-priority VMs are similar but have a few differences in behavior.
|**Supported Batch pool configurations**| Virtual Machine Configuration | Virtual Machine Configuration and Cloud Service Configuration (deprecated) |
38
-
|**Available regions**| All regions supporting[Spot VMs](../virtual-machines/spot-vms.md)| All regions except Microsoft Azure China 21Vianet |
39
-
|**Customer eligibility**| Not available to some subscription offer types. See more about [Spot limitations](../virtual-machines/spot-vms.md#limitations)| Available for all Batch customers |
37
+
|**Available regions**| All regions that support[Spot VMs](../virtual-machines/spot-vms.md)| All regions except Microsoft Azure China 21Vianet |
38
+
|**Customer eligibility**| Not available for some subscription offer types. See more about [Spot limitations](../virtual-machines/spot-vms.md#limitations).| Available for all Batch customers |
40
39
|**Possible reasons for eviction**| Capacity | Capacity |
41
40
|**Pricing Model**| Variable discounts relative to standard VM prices | Fixed discounts relative to standard VM prices |
42
41
|**Quota model**| Subject to core quotas on your subscription | Subject to core quotas on your Batch account |
@@ -46,40 +45,40 @@ Azure Spot VMs and Batch low-priority VMs are similar but have a few differences
46
45
47
46
Azure Batch provides several capabilities that make it easy to consume and benefit from Spot VMs:
48
47
49
-
- Batch pools can contain both dedicated VMs and Spot VMs. The number of each type of VM can be specified when a pool is created, or changed at any time for an existing pool, using the explicit resize operation or using autoscale. Job and task submission can remain unchanged, regardless of the VM types in the pool. You can also configure a pool to completely use Spot VMs to run jobs as cheaply as possible, but spin up dedicated VMs if the capacity drops below a minimum threshold, to keep jobs running.
48
+
- Batch pools can contain both dedicated VMs and Spot VMs. The number of each type of VM can be specified when a pool is created, or changed at any time for an existing pool, by using the explicit resize operation or by using autoscale. Job and task submission can remain unchanged, regardless of the VM types in the pool. You can also configure a pool to completely use Spot VMs to run jobs as cheaply as possible, but spin up dedicated VMs if the capacity drops below a minimum threshold, to keep jobs running.
50
49
- Batch pools automatically seek the target number of Spot VMs. If VMs are preempted or unavailable, Batch attempts to replace the lost capacity and return to the target.
51
50
- When tasks are interrupted, Batch detects and automatically requeues tasks to run again.
52
51
- Spot VMs have a separate vCPU quota that differs from the one for dedicated VMs. The quota for Spot VMs is higher than the quota for dedicated VMs, because Spot VMs cost less. For more information, see [Batch service quotas and limits](batch-quota-limit.md#resource-quotas).
53
52
54
53
## Considerations and use cases
55
54
56
-
Many Batch workloads are a good fit for Spot VMs. Consider using them when jobs are broken into many parallel tasks, or when you have many jobs that are scaled out and distributed across many VMs.
55
+
Many Batch workloads are a good fit for Spot VMs. Consider using Spot VMs when jobs are broken into many parallel tasks, or when you have many jobs that are scaled out and distributed across many VMs.
57
56
58
-
Some examples of batch processing use cases well suited to use Spot VMs are:
57
+
Some examples of batch processing use cases that are well suited for Spot VMs are:
59
58
60
59
-**Development and testing**: In particular, if large-scale solutions are being developed, significant savings can be realized. All types of testing can benefit, but large-scale load testing and regression testing are great uses.
61
60
-**Supplementing on-demand capacity**: Spot VMs can be used to supplement regular dedicated VMs. When available, jobs can scale and therefore complete quicker for lower cost; when not available, the baseline of dedicated VMs remains available.
62
-
-**Flexible job execution time**: If there's flexibility in the time jobs have to complete, then potential drops in capacity can be tolerated; however, with the addition of Spot VMs jobs frequently run faster and for a lower cost.
61
+
-**Flexible job execution time**: If there's flexibility in the time jobs have to complete, then potential drops in capacity can be tolerated. However, with the addition of Spot VMs, jobs frequently run faster and for a lower cost.
63
62
64
63
Batch pools can be configured to use Spot VMs in a few ways:
65
64
66
65
- A pool can use only Spot VMs. In this case, Batch recovers any preempted capacity when available. This configuration is the cheapest way to execute jobs.
67
66
- Spot VMs can be used with a fixed baseline of dedicated VMs. The fixed number of dedicated VMs ensures there's always some capacity to keep a job progressing.
68
-
- A pool can use a dynamic mix of dedicated and Spot VMs, so that the cheaper Spot VMs are solely used when available, but the full-priced dedicated VMs are scaled up when required. This configuration keeps a minimum amount of capacity available to keep the jobs progressing.
67
+
- A pool can use a dynamic mix of dedicated and Spot VMs, so that the cheaper Spot VMs are solely used when available, but the full-priced dedicated VMs scale up when required. This configuration keeps a minimum amount of capacity available to keep jobs progressing.
69
68
70
69
Keep in mind the following practices when planning your use of Spot VMs:
71
70
72
-
- To maximize use of surplus capacity in Azure, suitable jobs can scale out.
73
-
- Occasionally VMs may not be available or are preempted, which results in reduced capacity for jobs and may lead to task interruption and reruns.
74
-
- Tasks with shorter execution times tend to work best with Spot VMs. Jobs with longer tasks may be impacted more if interrupted. If long-running tasks implement checkpointing to save progress as they execute, this impact may be reduced.
75
-
- Long-running MPI jobs that utilize multiple VMs aren't well suited to use Spot VMs, because one preempted VM can lead to the whole job having to run again.
71
+
- To maximize the use of surplus capacity in Azure, suitable jobs can scale out.
72
+
- Occasionally, VMs might not be available or are preempted, which results in reduced capacity for jobs and could lead to task interruption and reruns.
73
+
- Tasks with shorter execution times tend to work best with Spot VMs. Jobs with longer tasks might be impacted more if interrupted. If long-running tasks implement checkpointing to save progress as they execute, this impact might be reduced.
74
+
- Long-running MPI jobs that utilize multiple VMs aren't well suited for Spot VMs, because one preempted VM can lead to the whole job having to run again.
76
75
- Spot nodes may be marked as unusable if [network security group (NSG) rules](batch-virtual-network.md#general-virtual-network-requirements) are configured incorrectly.
77
76
78
77
## Create and manage pools with Spot VMs
79
78
80
79
A Batch pool can contain both dedicated and Spot VMs (also referred to as compute nodes). You can set the target number of compute nodes for both dedicated and Spot VMs. The target number of nodes specifies the number of VMs you want to have in the pool.
81
80
82
-
For example, to create a pool using Azure virtual machines (in this case Linux VMs) with a target of 5 dedicated VMs and 20 Spot VMs:
81
+
The following example creates a pool using Azure virtual machines, in this case Linux VMs, with a target of 5 dedicated VMs and 20 Spot VMs:
Pool nodes have a property to indicate if the node is a dedicated or
111
-
Spot VM:
109
+
Pool nodes have a property to indicate if the node is a dedicated or Spot VM:
112
110
113
111
```csharp
114
112
bool?isNodeDedicated=poolNode.IsDedicated;
115
113
```
116
114
117
-
VMs may occasionally be preempted. When preemption happens, tasks that were running on the preempted node VMs are requeued and run again.
115
+
Spot VMs might occasionally be preempted. When preemption happens, tasks that were running on the preempted node VMs are requeued and run again when capacity returns.
118
116
119
117
For Virtual Machine Configuration pools, Batch also performs the following behaviors:
120
118
121
-
- The preempted VMs have their state updated to **Preempted**.
119
+
- The preempted VMs have their state updated to *Preempted*.
122
120
- The VM is effectively deleted, leading to loss of any data stored locally on the VM.
123
-
- A list nodes operation on the pool will still return the preempted nodes.
124
-
- The pool continually attempts to reach the target number of Spot nodes available. When replacement capacity is found, the nodes keep their IDs, but are reinitialized, going through **Creating** and **Starting** states before they're available for task scheduling.
121
+
- A list nodes operation on the pool still returns the preempted nodes.
122
+
- The pool continually attempts to reach the target number of Spot nodes available. When replacement capacity is found, the nodes keep their IDs, but are reinitialized, going through *Creating* and *Starting* states before they're available for task scheduling.
125
123
- Preemption counts are available as a metric in the Azure portal.
126
124
127
125
## Scale pools containing Spot VMs
128
126
129
-
As with pools solely consisting of dedicated VMs, it's possible to scale a pool containing Spot VMs by calling the Resize method or by using autoscale.
127
+
As with pools solely consisting of dedicated VMs, it's possible to scale a pool containing Spot VMs by calling the `Resize` method or by using autoscale.
130
128
131
-
The pool resize operation takes a second optional parameter that updates the value of **targetLowPriorityNodes**:
129
+
The pool resize operation takes a second optional parameter that updates the value of `targetLowPriorityNodes`:
The pool autoscale formula supports Spot VMs as follows:
138
136
139
-
- You can get or set the value of the service-defined variable **$TargetLowPriorityNodes**.
140
-
- You can get the value of the service-defined variable **$CurrentLowPriorityNodes**.
141
-
- You can get the value of the service-defined variable **$PreemptedNodeCount**. This variable returns the number of nodes in the preempted state and allows you to scale up or down the number of dedicated nodes, depending on the number of preempted nodes that are unavailable.
137
+
- You can get or set the value of the service-defined variable `$TargetLowPriorityNodes`.
138
+
- You can get the value of the service-defined variable `$CurrentLowPriorityNodes`.
139
+
- You can get the value of the service-defined variable `$PreemptedNodeCount`. This variable returns the number of nodes in the preempted state and allows you to scale up or down the number of dedicated nodes, depending on the number of preempted nodes that are unavailable.
142
140
143
141
## Configure jobs and tasks
144
142
145
143
Jobs and tasks may require some extra configuration for Spot nodes:
146
144
147
-
- The JobManagerTask property of a job has an **AllowLowPriorityNode** property. When this property is true, the job manager task can be scheduled on either a dedicated or Spot node. If it's false, the job manager task is scheduled to a dedicated node only.
145
+
- The `JobManagerTask` property of a job has an `AllowLowPriorityNode` property. When this property is true, the job manager task can be scheduled on either a dedicated or Spot node. If it's false, the job manager task is scheduled to a dedicated node only.
148
146
- The `AZ_BATCH_NODE_IS_DEDICATED`[environment variable](batch-compute-node-environment-variables.md) is available to a task application so that it can determine whether it's running on a Spot or on a dedicated node.
149
147
150
148
## View metrics for Spot VMs
@@ -155,7 +153,7 @@ New metrics are available in the [Azure portal](https://portal.azure.com) for Sp
155
153
- Low-Priority Core Count
156
154
- Preempted Node Count
157
155
158
-
To view these metrics in the Azure portal
156
+
To view these metrics in the Azure portal:
159
157
160
158
1. Navigate to your Batch account in the Azure portal.
161
159
2. Select **Metrics** from the **Monitoring** section.
@@ -165,12 +163,11 @@ To view these metrics in the Azure portal
165
163
166
164
- Spot VMs in Batch don't support setting a max price and don't support price-based evictions. They can only be evicted for capacity reasons.
167
165
- Spot VMs are only available for Virtual Machine Configuration pools and not for Cloud Service Configuration pools, which are [deprecated](https://azure.microsoft.com/updates/azure-batch-cloudserviceconfiguration-pools-will-be-retired-on-29-february-2024/).
168
-
- Spot VMs aren't available for some clouds, VM sizes, and subscription offer types. See more about [Spot limitations](../virtual-machines/spot-vms.md#limitations).
169
-
- Currently, [Ephemeral OS disks](create-pool-ephemeral-os-disk.md) aren't supported with Spot VMs due to the service managed
170
-
eviction policy of Stop-Deallocate.
166
+
- Spot VMs aren't available for some clouds, VM sizes, and subscription offer types. See more about [Spot VM limitations](../virtual-machines/spot-vms.md#limitations).
167
+
- Currently, [ephemeral OS disks](create-pool-ephemeral-os-disk.md) aren't supported with Spot VMs due to the service-managed eviction policy of *Stop-Deallocate*.
171
168
172
169
## Next steps
173
170
174
171
- Learn about the [Batch service workflow and primary resources](batch-service-workflow-features.md) such as pools, nodes, jobs, and tasks.
175
172
- Learn about the [Batch APIs and tools](batch-apis-tools.md) available for building Batch solutions.
176
-
- Start to plan the move from low-priority VMs to Spot VMs. If you use low-priority VMs with **Cloud Services Configuration** pools (which are [deprecated](https://azure.microsoft.com/updates/azure-batch-cloudserviceconfiguration-pools-will-be-retired-on-29-february-2024/)), plan to migrate to [**Virtual Machine configuration** pools](nodes-and-pools.md#configurations) instead.
173
+
- Start to plan the move from low-priority VMs to Spot VMs. If you use low-priority VMs with *Cloud Services Configuration* pools (which are [deprecated](https://azure.microsoft.com/updates/azure-batch-cloudserviceconfiguration-pools-will-be-retired-on-29-february-2024)), plan to migrate to [Virtual Machine Configuration pools](nodes-and-pools.md#configurations) instead.
0 commit comments