# Azure Spot Virtual Machines

> Chapter 67 of the Courseiva AZ-900 curriculum — https://courseiva.com/learn/az-900/azure-spot-instances

**Official objective:** 2.2 — Azure Architecture Services

## Introduction

This chapter covers Azure Spot Virtual Machines, a cost-saving option for workloads tolerant of interruption. AZ-900 tests this under objective 2.2, as a cost-related compute option.

## Discount Airline Seats, Not the Full-Price Ones

Airlines sell seats at regular price and also sometimes offer deeply discounted seats that the airline can cancel (to sell at full price) if demand spikes. Azure Spot Instances work similarly — they're heavily discounted virtual machine pricing, in exchange for the possibility that Azure can reclaim them if capacity is needed elsewhere. You save money by betting that you can tolerate the interruption.

## Core explanation

### What Spot Instances are
Azure Spot Virtual Machines are virtual machines available at a significantly discounted price (often 70-90% off standard pricing) in exchange for the acceptance that Azure can reclaim them at any time if capacity is needed for standard, full-price instances.

### Suitable and unsuitable workloads
Spot Instances fit workloads that can tolerate interruption without significant impact — batch processing jobs, non-critical development/test environments, or analysis workloads. They don't fit production services or workloads requiring guaranteed availability, since interruption would be problematic.

### How they fit cost management strategy
For workloads that can use them, Spot Instances dramatically reduce cloud costs, fitting the broader consumption-based pricing and cost optimization themes covered in earlier chapters.

### They're not guaranteed to be available
Availability depends on capacity and demand — sometimes Spot capacity is unavailable at all, and you'd need to use standard instances instead.

## Real-world context

A company running batch analysis jobs on a schedule uses Spot Instances for most of the computation, saving 80% on compute costs compared to standard instances. Jobs that fail due to interruption are automatically restarted, tolerating the occasional interruption.

## Exam focus

Objective 2.2 expects candidates to understand Spot Instances as a cost-saving option for workloads tolerant of interruption, not a universally applicable choice for every workload.

A common wrong answer is assuming Spot Instances are always cheaper without recognizing the interruption tradeoff — they're only appropriate for specific workload types.

Stable terms: **Spot Instances**, **interruption**. Memory trick: Spot Instances = huge discount (70-90% off), but Azure can reclaim them anytime — only suitable for workloads tolerant of interruption.

## Step by step

1. **Identify suitable workloads** — Workloads that can tolerate interruption are candidates for Spot Instances — batch jobs, development/test, analysis.
2. **Accept the tradeoff** — Accept that the instance can be reclaimed at any time in exchange for the steep discount.
3. **Handle interruption gracefully** — Workloads should be designed to handle interruption gracefully — save state frequently if data loss on interruption would be problematic.
4. **Set an eviction policy** — Configure how the instance should behave when reclaimed — either deallocate (pause and try to restart later) or delete (terminate completely).

## Comparisons

### Standard Virtual Machines vs Spot Instances

**Standard Virtual Machines:**
- Full price
- Guaranteed availability
- Suitable for all workloads
- Right choice for production/availability-critical

**Spot Instances:**
- 70-90% discount
- Can be reclaimed anytime
- Suitable only for interruption-tolerant workloads
- Right choice for cost-sensitive batch/dev/test

## Common misconceptions

- **Misconception:** Spot Instances are the right choice for all cost-sensitive workloads. **Reality:** They're only appropriate for workloads that can tolerate interruption — production services or availability-critical workloads shouldn't use them.
- **Misconception:** Spot Instance availability is guaranteed. **Reality:** Spot capacity is available only when Azure has surplus capacity — sometimes it's unavailable, and you'd need to use standard instances instead.

## Key takeaways

- Azure Spot Instances offer steep discounts (70-90% off standard pricing) in exchange for accepting that Azure can reclaim them anytime.
- They're suitable only for workloads tolerant of interruption — batch processing, development/test, analysis.
- They're not appropriate for production services or workloads requiring guaranteed availability.
- Spot capacity is available only when Azure has surplus capacity — availability is not guaranteed.

## FAQ

**What are Azure Spot Instances?**

They're virtual machines available at steep discounts (typically 70-90% off standard pricing) in exchange for accepting that Azure can reclaim them at any time if capacity is needed elsewhere.

**What workloads are suitable for Spot Instances?**

Workloads that can tolerate interruption without significant impact — batch processing jobs, development/test environments, analysis workloads. Production services or availability-critical workloads should not use them.

**Are Spot Instances always available?**

No — Spot capacity depends on Azure's available surplus capacity. Sometimes Spot is unavailable, and you'd need to use standard instances instead.

---

Interactive version with quiz and diagrams: https://courseiva.com/learn/az-900/azure-spot-instances
