DEV Community

Abdelrahman Farag
Abdelrahman Farag

Posted on

Your Karpenter Spot NodePool Probably Has a Hidden Mass-Extinction Risk — Here Is How I Tested It

Running Kubernetes workloads on Amazon EC2 Spot instances behind Karpenter (karpenter.sh/v1) is one of the fastest ways to cut an EKS compute bill by 50%–65%.


Until an Availability Zone capacity tightening or a popular CPU family recall hits.

When multiple Spot nodes in the same AZ or processor family (for example, Graviton3 c7g/m7g) get reclaimed inside the same two-minute window, a Spot-heavy NodePool does not degrade gracefully—it can suffer a correlated blackout.

Over the past few weeks, I built an open-source capacity simulator and karpenter.sh/v1 manifest synthesizer (AegisScale) to measure this exact failure mode—first across five real public production traces (including the October 2024 Microsoft Azure Multimodal LMM Inference trace from ModServe) and a 28-million-event discrete-event queue simulator, and then on a real 4-node Kubernetes (kind) cluster under live concurrent HTTP traffic.

Here is what actually broke, what survived, and the concrete karpenter.sh/v1 pattern that stopped the outage.


The Live 4-Node Kubernetes (kind) Test

To avoid relying purely on analytical queueing formulas, I spun up a 4-node kind cluster (1 control-plane + 3 worker nodes labeled on-demand/us-east-1a, spot/us-east-1b, and spot/us-east-1c), deployed an HTTP service doing ~8 ms of deterministic CPU work per request, and replayed a 60-second scaled burst from the October 2024 Azure trace (2,230 real concurrent async HTTP requests per run).

At t = 20s and t = 25s, right during the traffic surge, I injected a correlated dual-AZ Spot reclamation using real Kubernetes node drains:

kubectl cordon aegis-emulation-worker2
kubectl drain aegis-emulation-worker2 --ignore-daemonsets --delete-emptydir-data --force --grace-period=5
Enter fullscreen mode Exit fullscreen mode

What Happened

Setup Total Requests HTTP Error Rate Post-Drain Error Rate (t >= 20s) Min Ready Pods Real HTTP P99
Unhedged Greedy Spot (4 Spot pods across 2 AZs, no OD anchor) 2,230 60.58% (1,351 failed) 79.99% 0 (full blackout) 124.4 ms (surviving only)
On-Demand Anchor + Diversified Spot (3 OD + 4 Spot, PDB + preStop) 2,230 0.00% (0 failed) 0.00% 3 115.6 ms

Two details stood out immediately:

  1. Unhedged Spot did not just spike latency—it blacked out completely from t = 30s to t = 59s, taking 60.6 seconds after uncordon to recover.
  2. Graceful termination (preStop sleep + PodDisruptionBudget) + an explicit On-Demand anchor absorbed 100% of the burst with zero failed HTTP requests while still keeping the majority of fleet capacity on Spot (~39% estimated savings vs. all-On-Demand).

The Practical karpenter.sh/v1 Split That Prevents Mass Extinction

Instead of putting everything into a single Spot NodePool and hoping price-capacity-optimized saves you during a regional recall, split your scheduling into:

  1. A guaranteed On-Demand anchor NodePool sized to your baseline survival floor (e.g., 25%–35% of peak safe capacity), and
  2. AZ-partitioned, multi-family Spot NodePools with explicit CPU/memory limits so no single AZ or CPU family exceeds ~22% of total capacity.

Here is the minimal karpenter.sh/v1 structure:

apiVersion: karpenter.sh/v1
kind: NodePool
metadata:
  name: aegis-ondemand-anchor
spec:
  weight: 100
  limits:
    cpu: "24"
    memory: 96Gi
  disruption:
    consolidationPolicy: WhenEmptyOrUnderutilized
    consolidateAfter: 60s
  template:
    spec:
      nodeClassRef:
        group: karpenter.k8s.aws
        kind: EC2NodeClass
        name: aegis-al2023-default
      requirements:
        - key: karpenter.sh/capacity-type
          operator: In
          values: ["on-demand"]
        - key: topology.kubernetes.io/zone
          operator: In
          values: ["eu-west-1a", "eu-west-1b", "eu-west-1c"]
        - key: karpenter.k8s.aws/instance-family
          operator: In
          values: ["m7g", "c7g", "r7g"]
---
apiVersion: karpenter.sh/v1
kind: NodePool
metadata:
  name: aegis-spot-az-b
spec:
  weight: 50
  limits:
    cpu: "20"
    memory: 80Gi
  template:
    spec:
      nodeClassRef:
        group: karpenter.k8s.aws
        kind: EC2NodeClass
        name: aegis-al2023-default
      requirements:
        - key: karpenter.sh/capacity-type
          operator: In
          values: ["spot"]
        - key: topology.kubernetes.io/zone
          operator: In
          values: ["eu-west-1b"]
        - key: karpenter.k8s.aws/instance-family
          operator: In
          values: ["c6a", "c7g", "m6a", "m7g", "r7g"]
Enter fullscreen mode Exit fullscreen mode

Pair this with a PodDisruptionBudget and a short preStop hook (sleep 2 to let kube-proxy / ALB endpoints drain cleanly before SIGTERM) on your Deployment.


Two Honest Operational Limits Nobody Mentions

While testing this across real AWS CloudWatch and 2024 Azure traces, two hard boundaries showed up that are worth keeping in mind before going all-in on Spot:

  1. The 120-Second Cold-Start Wall: In a 1-minute resolution simulation with Spot eviction, proactive sizing beats reactive HPA cleanly when nodes boot in 0–60s. Once heavy container image pulls push node readiness to >= 120 seconds, replacement nodes cannot finish booting inside AWS's two-minute Spot interruption notice. If your pods pull multi-GB images, you need EKS Warm Pools or pre-cached Bottlerocket/AL2023 EBS snapshots—no autoscaling algorithm can beat physics.
  2. The Savings Plan Break-Even (~1.45x Spot Price): Comparing hedged Spot against pure On-Demand yields 32%–36% savings at 99%+ P99 SLA continuity. Against a fairer 1-Year AWS Compute Savings Plan + On-Demand baseline, the net margin narrows to 18%–31%—and on steady diurnal workloads, if Spot prices rise above ~1.45x baseline, a committed Savings Plan actually becomes cheaper than hedged Spot.

Code & Interactive Sandbox

I open-sourced the full benchmark suite, 28M-event discrete-event simulator, kind emulation script, and preprint write-up on GitHub:

Curious how other EKS/Karpenter teams are sizing their On-Demand floor vs. Spot split (and handling multi-AZ recalls in practice)—happy to compare notes in the comments.

Top comments (6)

Collapse
 
userxnom profile image
Abdullah Naseer •

This is the clearest framing of Spot risk I have seen — most Karpenter guides treat AZ and family diversification as a cost tweak, not a correlated-failure problem. The unhedged setup collapsing to a 60.6% error rate and a full blackout, versus 0% failed requests with a 25–35% On-Demand anchor, makes the trade-off impossible to hand-wave away. The detail I would have missed is the 120-second cold-start wall: once image pulls push node readiness past AWS's two-minute interruption notice, no amount of HPA can save you. Did the kind test show whether pre-warming images or smaller base images moved that 120-second boundary at all, or was the wall dominated by node provisioning itself?

Collapse
 
ahafarag profile image
Abdelrahman Farag •

Great question—thanks for reading closely!

To be completely transparent about the two measurements:

  • In the local kind test, we pre-loaded a slim python:3.11-slim image onto the nodes (kind load docker-image), so image pull time was ~0s and the 60.6s recovery in the unhedged run was purely Kubernetes rescheduling, container startup, and readiness probes.
  • The 120-second wall came from our 1-minute resolution cold-start sweep (0s, 60s, 120s, 180s total node-to-ready lag with Spot eviction). At 60s total boot time, proactive sizing still held 93.8% continuity (vs. 87.9% for reactive HPA), whereas crossing 120s dropped continuity to 75.3%.

In live EKS with Karpenter, EC2 launch + Bottlerocket/AL2023 kubelet join typically takes ~35–55s on its own—leaving roughly 65 seconds of headroom inside AWS's 2-minute Spot notice. So image size is usually the exact lever that pushes teams over the 120s cliff: shrinking base images, pre-baking heavy layers into EBS snapshots, or using SOCI lazy-loading is what pulls total readiness back under 120s.

Are you running heavy container images (ML/Java) on Karpenter right now, or mostly slim API services?

Collapse
 
userxnom profile image
Abdullah Naseer •

Thanks for the transparent breakdown — the split between the 60.6s rescheduling time and the 120s cliff makes the whole post click for me. I have to be honest: I am not running Karpenter myself. My world is one offline-first Android app with no backend, so I am reading this as a learner, not an operator. The part that stuck with me is that image size is the lever that pushes teams over the cliff — that maps exactly to what I see on mobile, where app size quietly becomes a product problem. In your own setup, which of those three fixes — slimming images, pre-baking layers, or SOCI — bought you the most headroom?

Collapse
 
upordownonline profile image
upordown.online •

Was the Karpenter interruption queue part of the picture? The kind drains are the polite version of a Spot reclaim: cordon, evict, respect the PDB, run preStop. On EKS, Karpenter only gets the two-minute warning if settings.interruptionQueue points at an SQS queue fed by the EventBridge rules, and without it the node mostly just goes away with far less ceremony than a drain. I'd expect the unhedged numbers to look even worse in that case, which makes the On-Demand anchor argument stronger.

Collapse
 
kursatyz profile image
Kürşat Yılmaz •

Correlated Spot interruptions inside a tightly constrained Karpenter NodePool turn AWS's 2-minute termination notice into a synchronized eviction storm, saturating CNI IPAM and kube-scheduler while replacement pods thrash on cold image pulls. Without an explicit On-Demand fallback NodePool and broad instance-family diversification, PodDisruptionBudgets just serialize the outage. Cheap compute dies in herds.

Collapse
 
mujtbabbas profile image
Syed Mujtaba •

The cold-start wall is the part that translates beyond Spot for me. I don't run EKS/Karpenter in production, so I won't pretend to have a floor number from my own clusters — but the same 120-second problem shows up whenever a replacement node has to pull an image and boot the app before it can take traffic. For the Node and PHP services I work with, slimming the image and getting the app ready fast matters at least as much as the Spot/On-Demand split, because the anchor only helps if the new nodes are actually ready in time.