Azure

Azure Spot VMs

Save up to 90% on compute costs by using Azure's unused capacity for interruptible workloads

What Are Azure Spot VMs?

Azure Spot VMs let you purchase unused Azure compute capacity at massive discounts—up to 90% off pay-as-you-go prices. The catch? Azure can evict your VM with 30 seconds notice when it needs the capacity back for regular customers.

Think of Spot VMs like standby airline tickets: Airlines sell empty seats at steep discounts to standby passengers, but if a full-fare customer shows up, the standby passenger gets bumped. Same concept. Azure sells unused compute capacity cheaply, but reserves the right to reclaim it when needed.

The Core Trade-off

What You Get

  • 60-90% cost savings
  • Same VM performance (not throttled)
  • Full Azure feature set
  • Perfect for flexible workloads

What You Risk

  • 30-second eviction notice
  • No SLA (no uptime guarantee)
  • VM can disappear anytime
  • Requires fault-tolerant architecture

How Spot VM Pricing Works

Dynamic Pricing Model

Spot VM prices fluctuate based on supply and demand in each Azure region. When Azure has excess capacity, Spot prices drop. When demand is high, prices rise (potentially to pay-as-you-go rates).

Example: Standard_D4s_v3 VM (4 vCPU, 16GB RAM)

Pricing ModelHourly RateMonthly CostSavings
Pay-as-you-go$0.192$140-
1-Year Reserved$0.118$8639% off
Spot VM (typical)$0.019$1490% off

Bottom Line: A VM that costs $140/month pay-as-you-go can run for $14/month as a Spot VM. That's the same price as running it for just 73 hours at regular rates. If you can tolerate interruptions, the savings are extraordinary.

Illustrative Financial Impact

This is a hypothetical, illustrative example for teaching purposes, not an actual case study.

Scenario: SaaS Company with CI/CD Pipeline & Batch Processing

Company runs continuous integration builds (40 VMs), nightly data processing jobs (30 VMs), and dev/test environments (20 VMs). All of these workloads are interruptible—if a VM disappears, the job can restart elsewhere.

Current State: Pay-as-you-go VMs

Workload TypeVM CountVM SizeMonthly Cost
CI/CD Build Agents40D4s_v3 (4 vCPU, 16GB)$5,600
Nightly Batch Processing30D8s_v3 (8 vCPU, 32GB)$8,400
Dev/Test Environments20D4s_v3 (4 vCPU, 16GB)$2,800
Total Monthly Cost$16,800

After Migrating to Spot VMs:

Workload TypeVM CountSpot SavingsMonthly Cost
CI/CD Build Agents4090% off$560
Nightly Batch Processing3090% off$840
Dev/Test Environments2090% off$280
Total Monthly Cost$1,680

Annual Impact:

$15,120Monthly savings
$181,440Annual savings
90%Cost reduction

Bottom Line: By migrating interruptible workloads to Spot VMs, this company saves $181K annually. The workloads are already designed to handle failures (CI/CD can retry builds, batch jobs checkpoint progress, dev/test environments can restart), so evictions are handled gracefully at minimal operational cost.

P&L Impact: Before and After Spot VMs

Let's see how Spot VMs affect the financial statements for a $12M ARR SaaS company:

Annual Profit & Loss Statement

P&L Line ItemBefore Spot VMsAfter Spot VMs
Revenue$12,000,000$12,000,000
Cost of Revenue:
Production infrastructure (Azure)($400,000)($400,000)
CI/CD + Batch + Dev/Test (Azure)($201,600)($20,160)
Other COGS($300,000)($300,000)
Gross Profit$11,098,400$11,279,840
Gross Margin %92.5%94.0%
Operating Expenses (R&D, S&M, G&A)($9,000,000)($9,000,000)
Operating Income (EBIT)$2,098,400$2,279,840
Operating Margin %17.5%19.0%

Key Financial Improvements:

+$181,440Operating income increase — 8.6% higher profitability
+1.5ppOperating margin expansion — 17.5% → 19.0%
+1.5ppGross margin improvement — 92.5% → 94.0%
-90%COGS reduction — non-production workloads

Why This Matters: Moving non-production workloads to Spot VMs improved operating margin by 1.5 percentage points. For SaaS companies, every point of margin matters—investors benchmark on Rule of 40 (growth + margin ≥ 40%). With 25% growth, this company went from 42.5 (17.5% margin) to 44.0 (19% margin)—strengthening their investor story with zero impact to customer-facing services.

Perfect Use Cases for Spot VMs

When to Use Spot VMs

Spot VMs are ideal for workloads that can tolerate interruptions and restart automatically:

CI/CD Pipelines

Build agents, test runners, deployment workers. If evicted, the build simply retries on another VM. Typical savings: 85-90%.

Batch Processing

Data pipelines, ETL jobs, report generation. Use checkpointing to save progress. If evicted, resume from last checkpoint. Savings: 80-90%.

Dev/Test Environments

Developer workstations, QA environments, staging. Eviction just means "restart the VM." Developers don't notice. Savings: 85-90%.

Rendering & Encoding

Video transcoding, 3D rendering, image processing. Jobs are queued and retried if interrupted. Perfect Spot VM candidate. Savings: 85-90%.

Big Data & Analytics

Spark clusters, Hadoop jobs, ML training. Frameworks handle node failures gracefully. Use Spot for worker nodes, regular VMs for master. Savings: 70-85%.

Scientific Computing

Simulations, genomic analysis, HPC workloads. Long-running but can checkpoint. If evicted, save state and resume. Savings: 80-90%.

When NOT to Use Spot VMs

Bad Use Cases for Spot VMs

Avoid Spot VMs for mission-critical or customer-facing workloads:

  • Production web servers: Customer-facing apps need uptime SLAs. Evictions = downtime = bad customer experience.
  • Production databases: Database evictions cause data inconsistency and downtime. Never use Spot for stateful data stores.
  • Stateful applications without checkpointing: If your app can't save progress and restart, Spot is too risky.
  • Long-running critical processes: Jobs that take days/weeks and can't be interrupted (e.g., critical month-end financial reports).
  • Load balancer-managed production pools: While technically possible, managing evictions in production is complex and risky.
  • Real-time/low-latency services: APIs, WebSocket servers, IoT ingestion. Evictions break connections.

Rule of Thumb: If losing the VM would impact customers, break SLAs, or lose unsaved data → don't use Spot. If it's a background job that can retry → Spot is perfect.

Handling Evictions: Architecture Patterns

How to Build Eviction-Tolerant Systems

Azure gives you 30 seconds warning before evicting a Spot VM via the Azure Metadata Service. Here's how to architect for graceful handling:

1

Monitor the Eviction Event

Poll the Azure Metadata Service every 5-10 seconds:

curl -H "Metadata:true" "http://169.254.169.254/metadata/scheduledevents?api-version=2020-07-01"

If response includes "Preempt" event → you have 30 seconds.

2

Checkpoint Your Progress

Save state to durable storage (Azure Storage, Cosmos DB, message queue) every few minutes. On eviction, save final state and exit gracefully. When job resumes on new VM, load checkpoint and continue.

3

Use Queue-Based Work Distribution

Don't assign work directly to VMs. Use Azure Storage Queue or Service Bus. Workers pull jobs, process them, and mark complete. If a worker disappears (eviction), the message becomes visible again and another worker picks it up. Zero data loss.

4

Mix Spot and Regular VMs

For large clusters (Spark, Kubernetes), use regular VMs for control plane/master nodes and Spot VMs for worker nodes. Workers can disappear without breaking the cluster. Typical mix: 10% regular, 90% Spot.

5

Over-Provision Workers

If you need 40 workers, provision 50 Spot VMs. When evictions happen, you still have capacity. The cost savings (90% off) mean you can afford over-provisioning.

Implementation Steps

How to Deploy Spot VMs

Azure Portal:

  1. Create a new VM → Select size
  2. Go to Basics tab → Under "Azure Spot discount", check "Yes, run as Spot instance"
  3. Set eviction policy: "Deallocate" (cheaper) or "Delete" (simpler)
  4. Set max price: "-1" (pay up to pay-as-you-go) or specific price cap
  5. Complete VM creation → Enjoy 80-90% savings!

Azure CLI:

az vm create \
  --resource-group myRG \
  --name mySpotVM \
  --image UbuntuLTS \
  --size Standard_D4s_v3 \
  --priority Spot \
  --max-price -1 \
  --eviction-policy Deallocate

Virtual Machine Scale Sets (VMSS):

For large deployments, use VMSS with Spot priority:

  1. Create VMSS → Set "Priority" to "Spot"
  2. Enable automatic eviction handling (VMSS replaces evicted VMs automatically)
  3. Set overprovision to true (deploy extra VMs to buffer evictions)

Monitoring & Tools

Tools for Managing Spot VMs

Azure Native Tools:

  • Azure Monitor: Track eviction rates and Spot VM health
  • Azure Cost Management: Compare Spot vs pay-as-you-go spending
  • Azure Metadata Service: Detect eviction warnings (30-second notice)
  • Azure Advisor: Recommendations on which workloads to migrate to Spot

Third-Party Tools:

  • Turbo360: Spot VM optimization recommendations and cost tracking

Disclosure: Turbo360 is one of this site's supporting partners—see the homepage. Treat these figures as illustrative, not independently verified.

For Cloud Engineers

When pitching Spot VMs to leadership, emphasize these points:

  • Massive savings with minimal effort: "90% cost reduction on CI/CD and batch processing—$181K annual savings"
  • No customer impact: "Only non-production workloads move to Spot. Customer-facing services unchanged."
  • Proven pattern: "Netflix, Lyft, Airbnb use Spot/preemptible VMs at scale. This is industry-standard FinOps."
  • Fast ROI: "Migrate in 2 weeks, see 90% cost drop immediately. No architectural rewrites needed for queue-based jobs."
  • Margin improvement: "$181K savings improves operating margin by 1.5 percentage points—significant for investor metrics"
  • Fail-safe architecture: "We'll use eviction monitoring and checkpointing. If Spot isn't available, fallback to regular VMs automatically."

Executive Talking Point: "By migrating our CI/CD pipelines, batch processing, and dev/test environments to Azure Spot VMs, we can reduce infrastructure costs by $181K annually—a 90% reduction for these workloads. This improves our operating margin from 17.5% to 19.0%, strengthening our Rule of 40 performance. Zero customer impact, automatic failover to regular VMs if Spot unavailable, and we can implement in 2-3 weeks."

Ready for the Next Topic?

Continue your learning journey