Skip to content

Commit

Permalink
Merge pull request MicrosoftDocs#112 from avirishuverma/patch-1
Browse files Browse the repository at this point in the history
Create spot-placement-score.md
  • Loading branch information
ttorble authored Nov 19, 2024
2 parents 4833545 + 92f389a commit ff9d1bd
Show file tree
Hide file tree
Showing 3 changed files with 192 additions and 0 deletions.
2 changes: 2 additions & 0 deletions articles/virtual-machine-scale-sets/TOC.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,8 @@
href: use-spot.md
- name: Spot Priority Mix
href: spot-priority-mix.md
- name: Spot Placement Score (Preview)
href: spot-placement-score.md
- name: Reserved instances
href: /azure/cost-management-billing/reservations/save-compute-costs-reservations
- name: Azure Hybrid Benefit
Expand Down
188 changes: 188 additions & 0 deletions articles/virtual-machine-scale-sets/spot-placement-score.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
---
title: Spot Placement Score (Preview)
description: Learn how to use Azure Spot Placement Score to evaluate deployment success.
author: aviverma
ms.author: avirishuverma
ms.service: azure-virtual-machines
ms.subservice: azure-spot-vm
ms.topic: how-to
ms.date: 11/13/2024
ms.reviewer: ju-shim
---


# Spot Placement Score (Preview)

> [!IMPORTANT]
> The Spot Placement Score feature is currently in PREVIEW. See the [Supplemental Terms of Use for Microsoft Azure Previews](https://azure.microsoft.com/support/legal/preview-supplemental-terms/) for legal terms that apply to Azure features that are in beta, preview, or otherwise not yet released into general availability.
Spot Placement Score evaluates the likelihood of success for individual Spot deployments by considering parameters like desired Spot Virtual Machine (VM) count, VM size, and your deployment region or zone. This feature enables you to generate a placement score to deploy a desired number of Spot Virtual Machines (VMs) across various combinations of regions, zones, and VM sizes. By inputting lists of up to eight regions and five VM sizes, you can obtain placement scores categorized as either High, Medium, or Low. A score of High indicates that the deployment is highly likely to succeed while a score of Low indicates that the deployment has a low chance of success. These scores are based on analyses of Spot capacity allocation probability and the survivability of the specified number of Spot VMs within each region and VM size combination. This functionality enhances deployment planning by providing predictive insights into deployment success and optimizing resource allocation for your Spot VMs.

Using Spot Placement Score, you can achieve the following:

- A clear evaluation of how likely your Spot deployment is to succeed based on specified parameters.

- Identify the most suitable combination of regions and VM sizes to maximize Spot VM availability and survivability based on placement scores.

- Improve the overall success rate of deploying Spot VMs by applying data-driven placement scores, reducing the risk of capacity issues or failures during deployment.

## Cost

There are no costs associated with this feature.

## Considerations

- Spot placement scores serve purely as a recommendation based on certain data points like eviction rate and VM availability. A high placement score doesn't guarantee that the Spot request will be fully or partially fulfilled.

- Placement Scores are only valid at the time when it's requested. The same Placement Score isn't valid at a different time of the same day or another day. Any similarities are purely coincidental.

- The Spot Placement Score is only relevant if the Spot request has the same configuration as the Spot Placement Score configuration; desired count, VM size, location, and zone. In all other circumstances, the likelihood of getting available Spot capacity won't align with the placement score generated by the tool.

- Spot Placement Scores don't consider other constraints, such as Virtual Machine Scale Sets `SinglePlacementGroup`.

- A subscription's available Spot VM quota needs to be checked or requested separately.

- Spot Placement Score supports both regionally and zonally scoped placement score.

- Spot Placement Score API internally calls other GET APIs and is part of your GET call quota.

- A score of **High** or **Medium** doesn't guarantee allocation success or no evictions.


## Configure your Spot Placement Score
Configure your Spot Placement Score by defining your Spot specific requirements:
- Number of desired Spot VMs
- Up to five VM sizes
- Up to eight regions
- Availability zones

We recommend that the placement scores for each combination of subscription, desired count, region, zone, and VM size are cached, to avoid calling the API with the same configuration frequently within a short period of time. The suggested cache TTL is a minimum of 15 minutes and a maximum of 30 minutes.

### [Azure portal](#tab/portal)

Find the Spot Placement Score in the Spot tab of the Virtual Machine Scale Sets creation process in the Azure portal. The following steps instruct you on how to access this feature during that process.

1. Log in to the [Azure portal](https://portal.azure.com).

1. In the search bar, search for and select **Virtual Machine Scale Sets**.

1. Select **Create** on the **Virtual Machine Scale Sets** page.

1. In the **Spot** tab, turn on the Spot option under the **Save money with Spot** section.

1. Fill out the *Size*, *Region*, *Availability Zones*, and *Initial instance count* fields in the **Your Placement Score** section.

1. Click on **Save + Apply** to receive your placement score for this configuration.

### [REST API](#tab/rest-api)

Use the following REST API to get your Spot Placement Score. The Placement Score API supports the following versions: *2024-03-01-preview* and *2024-06-01-preview*. You need to add the Role-Based Access Control (RBAC) role "Compute Recommendations Role" and select the members to enable the subscription they want to run the API on (/azure/role-based-access-control/role-assignments-portal).

```
POST https://management.azure.com/subscriptions/{subscription}/providers/Microsoft.Compute/locations/{region}/placementScores/spot/generate?api-version={api-version}
```

```json
{
"desiredLocations": "",
"desiredSizes": [{
"sku": ""
}],
"desiredCount": "",
"availabilityZones": ""
}
```
Some important terminology to consider:

**Restricted SKU** is returned if the Spot VM SKU isn't available for the subscription.

**Data Not Found** is returned when the data necessary to generate a score or recommendation is either not found in upstream databases, or is found but the data lifespan is greater than what our service considers "fresh".

### [Azure CLI 2.0](#tab/cli)

Access Spot Placement Score using Azure CLI command [az compute-recommender spot-placement-recommender](/cli/azure/compute-recommender#az-compute-recommender-spot-placement-recommender).

```azurecli-interactive
az compute-recommender spot-placement-recommender \
--availability-zones <> \
--desired-count <> \
--desired-locations <> \
--desired-sizes <> \
--location <> \
--subscription <> \
```

### [Azure PowerShell](#tab/powershell)

Access the Spot Placement Score using Azure PowerShell command [Invoke-AzSpotPlacementScore](/powershell/module/az.compute/invoke-azspotplacementscore) to call the API endpoint. The placement scores can be found under the "PlacementScore" property in the response object. Replace all parameters with your specific details:

```azurepowershell-interactive
Invoke-AzSpotPlacementScore
-Location <String>
-SubscriptionId <String>
-AvailabilityZone
-DesiredCount <Int32>
-DesiredLocation <String[]>
-DesiredSize <IResourceSize[]>
```

---

## Examples

The following examples have scenario assumptions and a table with the results score to help you understand how Spot Placement Score works.

### Scenario 1
This table is an example of a request returning regionally scoped placement scores for multiple desired VM sizes and regions.

The following scenario assumptions apply to this example:
- **Desired locations:** `westus`, `eastus`
- **Desired sizes:** `Standard_D2_v2`, `Standard_D4_v2`
- **Desired count:** 100
- **Availability zones:** False

| SKU | Region | Availability zone | Is quota available? | Placement score |
|-----------------------------------|-------------|---------------------|--------------------|-------------------|
| Standard_D2_v2 | westus | False | True | High |
| Standard_D4_v2 | westus | False | True | Low |
| Standard_D2_v2 | eastus | False | True | Medium |
| Standard_D4_v2 | eastus | False | True | High |

### Scenario 2
This table is an example of a request returning zonally scoped placement scores for multiple desired VM sizes and regions.

The following scenario assumptions apply to this example:
- **Desired locations:** `westus`, `eastus`
- **Desired sizes:** `Standard_D2_v2`, `Standard_D4_v2`
- **Desired count:** 100
- **Availability zones:** True

| SKU | Region | Availability zone | Is quota available? | Placement score |
|-----------------------------------|-------------|---------------------|--------------------|-------------------|
| Standard_D2_v2 | westus | 1 | True | Medium |
| Standard_D2_v2 | westus | 2 | True | Medium |
| Standard_D2_v2 | westus | 3 | True | Medium |
| Standard_D4_v2 | westus | 1 | True | High |
| Standard_D4_v2 | westus | 2 | True | High |
| Standard_D4_v2 | westus | 3 | True | High |
| Standard_D2_v2 | eastus | 1 | True | Low |
| Standard_D2_v2 | eastus | 2 | True | Low |
| Standard_D2_v2 | eastus | 3 | True | Low |
| Standard_D4_v2 | eastus | 1 | True | Medium |
| Standard_D4_v2 | eastus | 2 | True | Medium |
| Standard_D4_v2 | eastus | 3 | True | Medium |


## Troubleshooting

| Status code | Type | Condition |
|-----------------------------------|-------------|---------------------|--------------------|
| 200 | Successful request | Spot Placement Score operations complete successfully. |
| 400 | Bad error request | At least one required input parameter isn't present, or the values of the provided parameters aren't valid. Produces a detailed error message about the failed request. |
| 429 | Too many requests | Unable to generate placement score due to hitting a rate limit. |
| 500 | Internal server error | The placement score generation failed. Produces a detailed error message about the failed request. |

## Next steps

> [!div class="nextstepaction"]
> [Learn about Spot Priority Mix](../virtual-machine-scale-sets/spot-priority-mix.md)
2 changes: 2 additions & 0 deletions articles/virtual-machines/TOC.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1033,6 +1033,8 @@
href: ./linux/spot-template.md
- name: Spot Priority Mix
href: /azure/virtual-machine-scale-sets/spot-priority-mix?toc=/azure/virtual-machines/toc.json
- name: Spot Placement Score (Preview)
href: /articles/virtual-machine-scale-sets/spot-placement-score?toc=/azure/virtual-machines/toc.json
- name: VM size recommendation
href: /azure/virtual-machine-scale-sets/spot-vm-size-recommendation?toc=/azure/virtual-machines/toc.json
- name: Error codes
Expand Down

0 comments on commit ff9d1bd

Please sign in to comment.