Running Production on Spot Instances Safely
Spot cuts compute bills by up to 90%, but AWS can take the machine back in two minutes. Here's how we run real production on it without paging anyone.
Key takeaways
- Production can run on EC2 Spot safely if the workload is stateless or restartable.
- Spread requests across many instance types and every AZ, use the price-capacity-optimized allocation strategy, and drain nodes on the two-minute interruption notice.
- Keep databases and other stateful primaries on an on-demand or reserved floor.
On this page
You can run production on EC2 Spot safely if three things hold: the workload is stateless or restartable, the request spans many instance types and every AZ with price-capacity-optimized allocation, and something drains the node within the two-minute interruption notice. Keep stateful primaries on an on-demand floor. Spot is spare EC2 capacity at up to 90% off on-demand.
Verified against
Amazon EC2 Spot docs (interruption notices, allocation strategies), Karpenter v1.15.1 (karpenter.sh/v1 API, released 2026-10-23), against the karpenter.sh NodePool and disruption docs. Checked October 2026.
The catch is the whole deal: AWS can reclaim the machine whenever it needs the capacity back, with two minutes of warning. For years that reputation kept spot pinned to "batch jobs only." We run a good chunk of our production fleet on it now, and the difference is entirely in how you set it up.
What actually belongs on spot
The question isn't "is this workload important." Everything in production is important. The question is "what happens when this specific instance disappears with two minutes notice."
Safe on spot:
- Stateless services. Web tiers, API servers, anything behind a load balancer that can lose a node and reschedule the pod elsewhere. If a replacement instance serves the same request, spot is fine.
- Batch and async work. ETL, video encoding, report generation. Worst case a job restarts. These are the textbook fit.
- CI runners. Build agents are ephemeral by design. Losing one mid-build costs you a retry, not data.
- Kubernetes worker nodes. Pods are already designed to move. This is where spot pays off hardest.
Not safe on spot:
- Stateful primaries. Your database writer, the leader of a consensus group, a single-replica cache holding warm state. Anything where losing the node means losing data or triggering a failover you didn't schedule. Keep these on on-demand or reserved capacity.
- Anything with a long, uninterruptible startup. If a node takes eight minutes to become useful, a two-minute eviction notice is a bad trade.
The honest rule we use: if you can't answer "the workload reschedules cleanly" without a pause, it doesn't go on spot yet.
Handling the two-minute notice
The two-minute interruption notice is the entire game. AWS publishes it two ways: an EventBridge event with detail-type EC2 Spot Instance Interruption Warning, and a spot/instance-action item in instance metadata. AWS recommends polling every 5 seconds and notes notices are best effort. Something in your stack has to watch for it and react. On the instance, with IMDSv2:
$ TOKEN=$(curl -s -X PUT "http://169.254.169.254/latest/api/token" \
-H "X-aws-ec2-metadata-token-ttl-seconds: 21600")
$ curl -s -H "X-aws-ec2-metadata-token: $TOKEN" \
http://169.254.169.254/latest/meta-data/spot/instance-action
{"action": "terminate", "time": "2026-10-31T08:22:00Z"}
A 404 means no interruption is scheduled.
React means three things, in order:
- Stop taking new work. Deregister the node from the load balancer, cordon it in Kubernetes, pull it out of the queue consumer group.
- Drain in-flight work. Let existing connections finish. Connection draining on the load balancer plus a sane pod termination grace period covers most of this.
- Checkpoint if you have to. For longer batch jobs, write progress somewhere durable so the restart picks up instead of starting over.
Two minutes is enough time for a graceful shutdown and not much else. Design for it and it's a non-event. Ignore it and every eviction becomes a spike of 502s.
Diversify or suffer
The single biggest lever on interruption frequency is diversification, and most teams get it wrong by asking for one instance type in one AZ. That's the worst possible spot request: you're competing for the narrowest possible pool, and when that pool tightens, everything you have goes at once.
Spread across many instance types and every AZ in the region. m6i.large, m6a.large, m5.large, m5a.large, m5n.large are near-interchangeable for a stateless service. Each is a separate capacity pool. If you'll accept fifteen instance types across three AZs, AWS is drawing from forty-five pools, and a shortage in one barely registers.
Then set the allocation strategy to price-capacity-optimized, which AWS itself marks as recommended for stateless services, microservices and batch. It picks the pools least likely to be interrupted, then the cheapest of those. Use capacity-optimized when restarting work is expensive (long CI, rendering, HPC). Do not use lowest-price for anything you care about: AWS's own docs say it carries the highest interruption risk, yet it is still the CLI default for EC2 Fleet, so set the strategy explicitly.
Kubernetes on spot
This is where we run most of our spot capacity, because Kubernetes already assumes nodes come and go. A few pieces have to be in place.
Node provisioning. We use Karpenter (our Karpenter provisioning patterns go deeper). It watches for unschedulable pods and launches the cheapest node that fits, and it's genuinely good at spot diversification if you give it room. Cluster Autoscaler works too, but Karpenter's flexibility across instance types maps naturally onto how spot wants to be used.
The termination handler. You need something that catches the interruption notice and cordons plus drains the node before AWS pulls it. Karpenter handles interruptions natively once you provision the SQS queue and EventBridge rules and pass --interruption-queue; it starts a replacement node in parallel with the drain. It does not act on rebalance recommendations, so on Cluster Autoscaler setups (or if you want those too) run the AWS Node Termination Handler.
PodDisruptionBudgets. These stop a drain from taking down too many replicas of one service at once. Without a PDB, a wave of evictions plus a rolling deploy can briefly leave you with zero healthy pods.
A Karpenter NodePool that captures the shape:
# k8s/karpenter/nodepool-spot.yaml
apiVersion: karpenter.sh/v1
kind: NodePool
metadata:
name: spot-general
spec:
template:
spec:
requirements:
- key: karpenter.sh/capacity-type
operator: In
values: ["spot"]
- key: kubernetes.io/arch
operator: In
values: ["amd64"]
- key: karpenter.k8s.aws/instance-category
operator: In
values: ["m", "c", "r"]
- key: karpenter.k8s.aws/instance-generation
operator: Gt
values: ["5"]
nodeClassRef:
group: karpenter.k8s.aws
kind: EC2NodeClass
name: default
disruption:
consolidationPolicy: WhenEmptyOrUnderutilized
consolidateAfter: 1m
limits:
cpu: "1000"
And a PodDisruptionBudget so drains stay polite:
# k8s/api/pdb.yaml
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: api-pdb
spec:
minAvailable: 75%
selector:
matchLabels:
app: api
The wide instance-category and Gt: "5" generation filter are doing the diversification work. Don't pin instance types by hand here; let Karpenter draw from the whole menu. It matters for consolidation too: Karpenter's docs say single-node spot-to-spot replacement requires at least 15 candidate instance types.
Mixed on-demand and spot
Pure spot is a bad bet for the baseline you can never drop below. Run a floor of on-demand or reserved capacity that keeps the service alive if spot dries up entirely, and put the elastic layer on top of it on spot. In Karpenter, a second NodePool for on-demand with a higher weight, plus pod topology spread and a PDB, gets you there. We land around 70-80% spot on stateless tiers and sleep fine.
This pairs with the rest of our cloud cost optimization work, and with when reserved, Savings Plans and spot each fit; spot is the biggest single move on the compute line, but only after the diversification and draining are real.
Questions people ask
How much warning do you get before a spot instance is interrupted?
Two minutes for stop or terminate. AWS emits an EC2 Spot Instance Interruption Warning EventBridge event and sets spot/instance-action in instance metadata, both on a best-effort basis, and recommends checking every 5 seconds. Hibernation is the exception: you get a notice but no two-minute lead, because hibernation starts immediately. A rebalance recommendation can arrive earlier as a softer signal.
Which spot allocation strategy should I use?
price-capacity-optimized for most workloads. As of October 2026, AWS labels it recommended for stateless apps, microservices, data jobs and batch, because it chooses pools with the most spare capacity and then the lowest price among them. Use capacity-optimized when an interruption is expensive to recover from. Avoid lowest-price, which AWS says has the highest interruption risk.
Do Savings Plans apply to spot instances?
No. AWS states Savings Plans don't add savings on top of spot pricing, and spot spend doesn't count toward a Compute Savings Plans commitment. Size your commitments against the on-demand floor you always run, and let spot cover the elastic layer above it. Committing to more than the floor means paying for coverage spot already undercuts.
The call we'd make
Put every stateless service and every Kubernetes worker on spot, diversified across a dozen-plus instance types with price-capacity-optimized, behind a proper termination handler and PDBs, on an on-demand floor you can't fall through. Keep stateful primaries off it. Do that and spot stops being a gamble and starts being the default, with the on-demand bill as the thing you have to justify.
Sources
Cite this article
Kiril Urbonas (2026). Running Production on Spot Instances Safely. DevOpsNess. Updated 2026-10-31. https://www.devopsness.com/blog/spot-instances-guide
[Running Production on Spot Instances Safely](https://www.devopsness.com/blog/spot-instances-guide) (Kiril Urbonas, DevOpsNess, updated 2026-10-31)
More from Cloud
Explore more articles in this category
.NET 8 Support Ends November 10: The Lambda and Azure Functions Checklist
.NET 8, .NET 9, the Lambda dotnet8 runtime and the Azure Functions in-process model all lose support on November 10, 2026. Inventory commands, the isolated-worker migration and a CI gate.
Google Cloud's europe-west2 Outage: One Zone Lost Power and the Region Stalled for 6 Hours
On October 20, 2026, europe-west2-b lost power when its generators never started. Cross-zone control-plane timeouts then degraded the whole London region. What happened and the gcloud audit to run now.
Lambda Python 3.10 Is Deprecated Today: Find Every Function and Move to 3.13
AWS deprecated the Lambda python3.10 runtime on October 31, 2026. Functions keep running, patches stop. The inventory commands, IaC diffs and AL2023 gotchas for moving to python3.13.
You might have missed
Evergreen posts worth revisiting.