Spot instances: lower-cost VMs for interruption-tolerant work
Understand Spot capacity, interruption risks, provider notices, and how to design restartable workloads.
What is a Spot instance?
A Spot instance or Spot VM uses spare cloud compute capacity at a discounted price. The provider can reclaim that capacity, so the VM can be interrupted while running. Spot fits work that can pause, retry, or restart. Do not rely on a Spot VM alone for a service that must remain continuously available or stores its only important state locally.
Compare compute choices
| Model | Benefit | Suitable work | Main risk |
|---|---|---|---|
| On-demand | Flexible launch and runtime | Uncertain schedules but interruption-sensitive services | Cost accumulates during sustained use |
| Spot | Discounted spare capacity | Batch jobs, rendering, tests, retryable workers | Capacity can be reclaimed and might not be available again immediately |
| Capacity reservation | Better assurance for a specified configuration and location | Recovery or planned peaks needing capacity assurance | Idle reserved resources can still cost money |
Spot is cheaper because it uses spare resources, not because it guarantees capacity. Prices and availability vary by provider, region, size, OS, and time. A price discount does not provide the availability assurance of a capacity reservation.
Interruption notices differ
Do not assume a warning will always arrive or provide enough time for a graceful shutdown. AWS EC2 generally gives a two-minute interruption notice, but delivery is best effort and hibernation does not get the same two-minute lead time. Azure Spot VMs receive 30 seconds' notice when capacity is reclaimed, but have no SLA or high-availability guarantee. Google Cloud Spot VMs signal preemption through metadata; the default best-effort shutdown period is up to 30 seconds. A 120-second preemption notice can be configured at creation, followed by a separate best-effort shutdown period.
Treat a notice as a brief chance to save state, not as guaranteed completion time. Persist progress outside the VM, stop accepting new work on notice, and make retries safe. Idempotency means repeating a task does not corrupt or duplicate its final result.
Design a workload that can recover
A good candidate is divisible work whose outputs are saved durably and whose failed parts can be rerun. Hypothetical example: an image-processing worker reads a job from a queue, stores the finished output and status in durable storage, then acknowledges the job. If reclaimed mid-task, the unconfirmed job can be retried by another worker. Frequent checkpoints or small tasks limit lost progress. This example is illustrative, not a tested deployment.
A single-VM database, an interactive critical server, or a long job that cannot resume is usually a poor fit unless you add independent recovery and redundancy. Even a group of Spot VMs can lose capacity together, and replacement capacity may be unavailable. Consider keeping critical baseline capacity on-demand or reserved and using Spot for retryable overflow.
Prepare and operate
Define acceptable interruption and rerun time, store state outside the VM, implement checkpoints and safe retries, and decide what happens when new Spot capacity cannot be obtained. Check current prices and historical interruption data for the chosen size and location; history is not a runtime guarantee. Monitor notices, queue depth, retry rate, failures, and storage that remains billable after interruption. Include disks, transfer, licenses, and rerun costs in the comparison. Test recovery behavior with the real workload. Spot does not create resilience by itself: application design and operations must provide it.
Official documentation
[AWS Spot interruptions](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-interruptions.html)
[AWS interruption notices](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/spot-instance-termination-notices.html)
[Azure Spot VMs](https://learn.microsoft.com/en-us/azure/virtual-machines/spot-vms)
[Google Cloud Spot VMs and preemption](https://docs.cloud.google.com/compute/docs/instances/spot)
[Create, use, and recover Spot VMs](https://docs.cloud.google.com/compute/docs/instances/create-use-spot)