How Priya’s Team Learned to Run Production on Spot Instances Without Burning Down the Platform

When an E-commerce Platform Nearly Collapsed During Black Friday: Priya’s Story

Priya was on call the night her platform hit its peak. Her small team had cut cloud costs by 60% the previous quarter by moving most of their fleet to spot instances. For weeks everything looked great: dashboards were green, margins improved, and leadership stopped breathing down their necks. Meanwhile the traffic surge for Black Friday started to climb and the spot pool started to shrink.

Two minutes after the first interruption notice, the search cluster started dropping nodes. Orders piled into a queue that couldn’t be processed fast enough. Checkout latency spiked. Third-party fraud checks timed out. Within an hour orders were failing and the incident went from noisy to catastrophic. The team scrambled, scaling on-demand instances only after significant damage to customer experience and revenue.

As it turned out, the team had done what many engineers do: they used spot instances as cheap copies of on-demand machines but without designing for preemption. They thought autoscaling groups and container orchestration would mask the problem. They were wrong. That night became a hard lesson in the difference between cost optimization and production reliability.

The Hidden Risk of Running Production on Spot Instances

Spot instances can reduce compute costs dramatically, often 60-90% compared with on-demand. That makes them tempting for production. The hidden risk is interruption. Providers can reclaim spot instances with little notice – often about two minutes – when capacity is needed elsewhere.

Spot interruptions are not just an occasional nuisance. They are a different failure mode that interacts with state, load patterns, and recovery logic. If your application depends on long-lived local state, or if eviction cascades into increased load on remaining nodes, the outage can amplify. In Priya’s case, queue depth, synchronous writes, and blocking health checks multiplied the impact.

Different clouds treat preemption differently. AWS provides a two-minute termination notice via instance metadata and tools like Spot Fleet and Auto Scaling with mixed instance policies. Google offers preemptible VMs with short lifetimes and no termination notice for some types. Azure uses eviction events with varying notice windows. As it turned out, understanding the exact eviction behavior is a necessary first step; treating spot instances as brittle on-demand machines is a recipe for trouble.

Why Traditional Spot Strategies Often Fall Short

Many mitigation approaches are half measures. They mask symptoms but fail under real stress. Here are common pitfalls and why they fail in production.

Thought experiment: stateless frontends vs stateful backends

Imagine two services: a stateless frontend and a stateful payment processor. If 10% of your frontend pool evaporates suddenly, you can usually route traffic to remaining nodes or spin up replacements. If 10% of your payment processors die mid-transaction, you risk dropped charges, inconsistent records, and painful rollbacks. Which one survives a surge in preemptions depends on architectural choices, not just instance counts.

Common anti-patterns

  • Running stateful workloads on ephemeral disks without replication
  • Relying on a single instance type or Availability Zone
  • Using naive autoscaling that reacts too slowly to interruption cascades
  • Assuming a two-minute notice will solve long-running in-memory job state
  • Not separating critical control plane services from spot-based worker nodes

Simple solutions like “set minimum capacity to 20%” or “run everything on mixed instances” sound reasonable but miss the interaction with load spikes and state. For example, setting a minimum capacity reduces savings and still doesn’t prevent synchronized eviction across similar instance types. Using single AZs reduces cross-AZ diversity and makes you vulnerable to localized capacity shortages. Naive autoscaling often ramps after the damage is done because it ties to CPU or request latency metrics that lag behind actual need.

How One Engineering Team Found a Reliable Way to Run Production on Spot Instances

Priya’s team rebuilt their spot strategy from the ground up. This wasn’t a single tool or trick. It was a layered approach that respected the property: spot is ephemeral, and systems must be built to absorb that ephemerality. Here are the elements they applied, and what each one buys them.

Diversify allocation – instance types, pricing models, and zones

  • Use mixed instance policies to spread capacity across many instance types and AZs so preemption probability is not correlated.
  • Prefer capacity-optimized allocation (or provider equivalents) over simple lowest-price selection. Price is not the only signal of long-term availability.
  • Keep a small on-demand or reserved baseline for critical path services.

Separate concerns: control plane vs workers

Critical control plane components (load balancers, API gateways, leader-election endpoints, databases) were moved off spot or given multi-AZ managed services. Worker fleets that can be retried safely were kept on spot. This led to fewer single points of failure and isolated the blast radius.

Graceful eviction handling and state migration

  • Implement termination handlers that receive the two-minute notice and trigger graceful shutdown – drain traffic, flush buffers, hand off leases.
  • For stateful work, move local state to replicated services: managed databases, distributed caches with high-availability, or S3-like object storage for checkpoints.
  • Use application-level checkpointing for long-running jobs and orchestrate retries from a durable queue.

Kubernetes-specific controls

They used Kubernetes constructs to reduce disruption: node termination handlers as DaemonSets, pod disruption budgets for critical pods, and priority classes to ensure essential services land on on-demand nodes when spot is scarce. This allowed the scheduler to prefer stable nodes for control plane and critical workloads.

Predictive and proactive scaling

Rather than only reactive autoscaling, they used predictive scaling based on historical traffic patterns and business events. Predictive rules pre-warmed capacity before known spikes and reduced the need for last-minute launches when spot capacity might be thin.

Robust observability and playbooks

They instrumented health-level metrics around queue depth, retry rates, and replication lag. Playbooks mapped metrics to actions: when queue depth crosses threshold X, scale on-demand baseline to Y and notify incident commander. This led to faster, consistent responses during interruptions.

Fallback and cost-aware policies

They implemented policies that trade cost for availability automatically. For example, if businessabc.net spot eviction rates exceeded predefined SLO impact, mixed instance groups would increase on-demand capacity to maintain SLA. This made cost reduction conditional on maintaining reliability.

Automation example – graceful termination flow

  • Instance receives termination notice.
  • Instance calls control endpoint to mark itself draining.
  • Load balancer stops sending new requests, long-running work is checkpointed.
  • Replicas are promoted if necessary; data is flushed to durable store.
  • Autoscaler replaces the lost capacity according to policy (prefer spot pool first, on-demand fallback if needed).
  • Implementing this required discipline: application engineers reworked shutdown logic, platform engineers updated autoscaling policies, and SREs defined the thresholds. It was a cross-functional fix, not a single team applying a checkbox.

    From Frequent Outages to 99.95% Availability: Real Results and Lessons

    Three months after the rebuild, Priya’s team ran another Black Friday. This time the dashboards told a different story. Spot pools still lost nodes, but graceful shutdowns and diversified capacity prevented order loss. Checkpointing meant jobs resumed without manual intervention. The control plane never used spot for core services, so the critical path remained stable.

    Concrete results they measured:

    • Availability improved from ~97% during peak traffic to 99.95%.
    • Recovery time from spot-driven incidents dropped from tens of minutes to under 2 minutes for worker replacement and under 5 minutes for full recovery in most cases.
    • Net cost savings remained high – roughly 50% reduction versus all on-demand – because they kept a small on-demand baseline and used spot for elastic workers.

    As it turned out, the real win wasn’t the absolute cost number. It was the predictability. They could set SLOs for cost and availability and know exactly how to shift the mix in response to signals. That predictability made product and finance teams comfortable with the approach.

    What to do next – a practical checklist

    • Audit which services are truly safe to run on spot. Separate them into safe workers, partially safe (with checkpoints), and unsafe (control plane, databases).
    • Deploy mixed instance policies with many instance types and multi-AZ targeting.
    • Implement graceful termination handlers and ensure two-minute notices are acted on.
    • Use managed durable storage and replicated services for any persistent data.
    • Set up predictive scaling for known traffic patterns and automated fallback to on-demand when spot availability sinks below thresholds.
    • Define SLOs that include cost and availability and automate tradeoffs between them.
    • Test preemption scenarios regularly with game days so teams learn to operate under real constraints.
    Strategy When to use Primary benefit Diversified mixed instances Elastic worker fleets Reduces correlated evictions On-demand baseline for control plane Critical services, leader election Maintains availability during spot shortages Graceful termination + checkpointing Long-running jobs, stateful services Prevents data loss and allows restart Predictive scaling Known traffic events Pre-warms capacity to avoid racing for spot

    Two thought experiments you should try

  • Simulate a 30% spot eviction across your main fleet during peak traffic. Track queue depth, latency, error rates, and time to restore SLA. If your recovery requires manual intervention, you need more automation.
  • Model the cost/availability curve: estimate costs at different on-demand baseline percentages (5%, 10%, 20%) and find the breakpoint where marginal reliability gains justify lost savings. Use that as your policy knob.
  • Meanwhile, don’t treat spot as a silver bullet. It’s a powerful tool when combined with architecture that assumes failure. The change Priya’s team made required code updates, platform improvements, and new operational runbooks. That work is not free, but it pays back in predictable cost and reliability gains.

    Final takeaway: if you want to run production on spot instances without getting burned, design for preemption from day one, separate critical control plane services from ephemeral worker pools, automate graceful shutdown and failover, and make cost a policy parameter rather than a binary goal. Do that and you turn spot from a risky gamble into a disciplined cost lever you can control.

    Posted by Derek Finnegan