Ecstaticloud
Initializing0%
Ecstaticloud Logo
Back to all insights
Enterprise AI & LLMOpsNovember 7, 2026• 8 min read

Architecting Zero-Downtime LLM Pipelines: How to Scale vLLM on AWS EKS Using Spot Instances

Discover how to cut your Generative AI infrastructure costs by up to 70% without sacrificing reliability or application latency. Learn how to engineer a resilient, auto-scaling vLLM inference cluster on AWS EKS powered by GPU spot instances and custom Prometheus metrics.

Running Large Language Model (LLM) workloads in production presents a brutal architectural paradox: high-performance GPU instances (like AWS g5.12xlarge or p4d.24xlarge) are exorbitantly expensive, yet LLM latency SLAs leave zero margin for performance degradation or service outages.

If you run your vLLM clusters entirely on On-Demand instances, your monthly AWS bill will look astronomical. If you naïvely switch to GPU Spot Instances, a single spot interruption can evict your active inference engines, drop active HTTP connections, purge warm Key-Value (KV) caches, and spike your P99 latency to infinity.

At Ecstaticloud, we engineered a zero-downtime, metric-driven inference architecture on Amazon EKS that leverages AWS Spot Instances for up to 70% cost reduction while maintaining strict 99.99% availability and sub-100ms Time-To-First-Token (TTFT) SLAs.

In this guide, we will walk through the exact production implementation, including Karpenter provisioning, vLLM engine configurations, zero-downtime graceful drain hooks, and Prometheus-driven KEDA autoscaling.


High-Level Architecture Overview

To achieve zero-downtime on volatile Spot instances, we decouple the stateless routing layer from the stateful inference engine layer and use proactive interruption handling rather than reactive Pod eviction.

                  +--------------------------+
                  |  AWS ALB / Gateway API   |
                  +-------------+------------+
                                |
                                v
                  +--------------------------+
                  |   Envoy Router / Ingress |
                  +-------------+------------+
                                |
        +-----------------------+-----------------------+
        | (Weighted Round Robin / Health-Checked)       |
        v                                               v
+-----------------------+               +-----------------------+
|  vLLM Pod (Spot)      |               |  vLLM Pod (On-Demand) |
|  - Active KV Cache    |               |  - Baseline Capacity  |
|  - PreStop Lifecycle  |               |  - Low Latency Fallback|
+-----------+-----------+               +-----------+-----------+
            |                                       |
            +-------------------+-------------------+
                                |
                                v
                  +--------------------------+
                  | Prometheus Metrics Engine|
                  | (vllm:num_requests_wait) |
                  +-------------+------------+
                                |
                                v
                  +--------------------------+
                  |   KEDA Custom Scaler     |
                  +-------------+------------+
                                |
                                v
                  +--------------------------+
                  |   Karpenter NodePool     |
                  | (Spot-First, OD Fallback)|
                  +--------------------------+

Architectural Principles

  1. Hybrid Capacity Strategy: 20% On-Demand baseline capacity to handle instant failover spikes, paired with 80% Spot instances for bulk workload handling.
  2. Proactive Interruption Interception: AWS EventBridge sends 2-minute Spot Interruption Notifications to Karpenter via SQS. Pods enter a graceful drain cycle before the host is terminated.
  3. KV Cache-Aware Routing: Requests are load-balanced to pods with active readiness probes that monitor GPU memory fragmentation and request queue length.
  4. LLM-Native Metrics Scaling: Autoscaling based on pending prompt queues (vllm:num_requests_waiting) rather than CPU/Memory metrics.

1. Dynamic GPU Provisioning with Karpenter

AWS Cluster Autoscaler is too slow for GPU spot operations; cold-booting an EC2 GPU node, downloading a 15GB HuggingFace model, and warming the CUDA context can take 3 to 5 minutes. Karpenter bypasses Node Groups and provisions nodes directly via AWS EC2 Fleet APIs in seconds.

Defining the Karpenter NodePool and EC2NodeClass

We define a NodePool that spans multiple instance families (g5, g6, p4d) across multiple Availability Zones to maximize AWS Spot pool availability.

apiVersion: karpenter.sh/v1beta1
kind: NodePool
metadata:
  name: vllm-gpu-spot
spec:
  template:
    metadata:
      labels:
        workload: vllm-inference
        capacity-type: spot
    spec:
      nodeClassRef:
        name: gpu-ec2-node-class
      requirements:
        - key: "karpenter.sh/capacity-type"
          operator: In
          values: ["spot", "on-demand"]
        - key: "instance.k8s.aws/instance-family"
          operator: In
          values: ["g5", "g6"]
        - key: "kubernetes.io/arch"
          operator: In
          values: ["amd64"]
        - key: "topology.kubernetes.io/zone"
          operator: In
          values: ["us-east-1a", "us-east-1b", "us-east-1c"]
      taints:
        - key: nvidia.com/gpu
          value: "true"
          effect: NoSchedule
  limits:
    resources:
      nvidia.com/gpu: "64"
  disruption:
    consolidationPolicy: WhenEmpty
    consolidateAfter: 300s
    expireAfter: 720h
---
apiVersion: karpenter.k8s.aws/v1beta1
kind: EC2NodeClass
metadata:
  name: gpu-ec2-node-class
spec:
  amiFamily: AL2
  amiSelectorTerms:
    - name: "amazon-eks-gpu-node-1.30-*"
  role: "KarpenterNodeRole-cluster"
  subnetSelectorTerms:
    - tags:
        karpenter.sh/discovery: "production-eks"
  securityGroupSelectorTerms:
    - tags:
        karpenter.sh/discovery: "production-eks"
  blockDeviceMappings:
    - deviceName: /dev/xvda
      ebs:
        volumeSize: 200Gi
        volumeType: gp3
        iops: 3000
        throughput: 125

Key Architectural Takeaway: Notice the provision for g5 and g6 families simultaneously. By allowing Karpenter to pull across g5.xlarge, g5.2xlarge, and g5.12xlarge, we avoid regional Spot capacity starvation.


2. Deploying vLLM Engine with High Availability Constraints

When running vLLM (v0.6.x+), tuning engine flags is vital to ensure maximum throughput without running into Out-Of-Memory (OOM) errors during heavy continuous batching.

Optimized vLLM Deployment Manifest

The following deployment configures:

  • Topology Spread Constraints across AZs.
  • Graceful termination period of 120 seconds (matching AWS Spot notification windows).
  • Custom Readiness/Liveness Probes targeting vLLM’s internal health endpoints.
apiVersion: apps/v1
kind: Deployment
metadata:
  name: vllm-llama3-8b
  namespace: vllm-serving
spec:
  replicas: 4
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 0
  selector:
    matchLabels:
      app: vllm-llama3-8b
  template:
    metadata:
      labels:
        app: vllm-llama3-8b
    spec:
      terminationGracePeriodSeconds: 120
      tolerations:
        - key: "nvidia.com/gpu"
          operator: "Exists"
          effect: "NoSchedule"
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - weight: 100
              podAffinityTerm:
                labelSelector:
                  matchExpressions:
                    - key: app
                      operator: In
                      values: ["vllm-llama3-8b"]
                topologyKey: topology.kubernetes.io/zone
      containers:
        - name: vllm-container
          image: vllm/vllm-openai:v0.6.0
          args:
            - "--model"
            - "meta-llama/Meta-Llama-3-8B-Instruct"
            - "--port"
            - "8000"
            - "--max-model-len"
            - "8192"
            - "--gpu-memory-utilization"
            - "0.90"
            - "--max-num-seqs"
            - "256"
            - "--enable-chunked-prefill"
          env:
            - name: HUGGING_FACE_HUB_TOKEN
              valueFrom:
                secretKeyRef:
                  name: hf-token-secret
                  key: token
          resources:
            limits:
              cpu: "8"
              memory: 32Gi
              nvidia.com/gpu: "1"
            requests:
              cpu: "6"
              memory: 24Gi
              nvidia.com/gpu: "1"
          ports:
            - containerPort: 8000
              name: http
          livenessProbe:
            httpGet:
              path: /health
              port: 8000
            initialDelaySeconds: 120
            periodSeconds: 10
          readinessProbe:
            httpGet:
              path: /health
              port: 8000
            initialDelaySeconds: 30
            periodSeconds: 5
          lifecycle:
            preStop:
              exec:
                command: ["/bin/sh", "-c", "sleep 15 && kill -SIGINT 1"]

3. Engineering Zero-Downtime Interruption Handling

The primary risk with Spot instances is abrupt termination. AWS issues a 2-minute warning via EventBridge when a Spot instance is marked for interruption.

Step 1: Karpenter Native Interruption Queue Setup

Karpenter listens directly to an AWS SQS queue populated by EventBridge events:

  • EC2 Spot Instance Interrupt Warning
  • EC2 Instance Rebalance Recommendation
  • EC2 Instance State-change Notification

When Karpenter consumes a termination event:

  1. It immediately marks the node as Cordoned (unschedulable).
  2. It emits a Taint (karpenter.sh/disrupted:NoSchedule).
  3. It starts provisioning a replacement node before deleting the current Pod.

Step 2: Connection Draining via Lifecycle Hooks

To prevent dropped inflight LLM streams, we use Kubernetes Pod Lifecycle hooks and HTTP routing draining.

AWS EventBridge (Spot Interruption Signal)
              | (2-Minute Warning)
              v
Karpenter Interruption Queue (SQS)
              |
              +---> Cordon & Taint Node
              |
              +---> Issue SIGTERM to Pod
                      |
                      v
       +-------------------------------+
       | vLLM PreStop Lifecycle Hook  |
       +---------------+---------------+
                       |
                       +---> 1. Set Readiness Probe to 503 (Remove from ALB)
                       |
                       +---> 2. Flush/Finish Active Continuous Batches (15-30s)
                       |
                       +---> 3. Shut down vLLM Process cleanly

The preStop hook script executed inside the vLLM container drains in-flight requests cleanly:

#!/bin/bash
# PreStop Drain Script for vLLM

echo "Spot Interruption Signal Received. Initiating Graceful Drain..."

# Step 1: Touch a file that triggers the custom readiness probe to return 503
touch /tmp/drain_started

# Step 2: Wait for AWS ALB/Kubernetes Service endpoints to propagate endpoint removal
sleep 10

# Step 3: Monitor vLLM internal metrics for active requests reaching zero
METRIC_URL="http://localhost:8000/metrics"

while true; do
  WAITING_REQ=$(curl -s $METRIC_URL | grep 'vllm:num_requests_waiting' | awk '{print $2}')
  RUNNING_REQ=$(curl -s $METRIC_URL | grep 'vllm:num_requests_running' | awk '{print $2}')
  
  if [ -z "$WAITING_REQ" ]; then WAITING_REQ=0; fi
  if [ -z "$RUNNING_REQ" ]; then RUNNING_REQ=0; fi
  
  TOTAL=$(($WAITING_REQ + $RUNNING_REQ))
  echo "Current Active Requests: $TOTAL (Running: $RUNNING_REQ, Waiting: $WAITING_REQ)"
  
  if [ "$TOTAL" -eq 0 ]; then
    echo "All requests drained successfully. Terminating process."
    break
  fi
  
  sleep 2
done

4. Metric-Driven Auto-Scaling with KEDA & Prometheus

Traditional Kubernetes autoscaling using CPU/Memory metrics is completely useless for LLM engines. A vLLM instance allocating CUDA memory for its KV cache will report ~90% memory utilization constantly, even if it is processing zero requests.

Instead, we must scale on vLLM-native metrics:

  • vllm:num_requests_waiting: The count of prompts queued up in memory waiting for KV cache allocation.
  • vllm:gpu_cache_usage_perc: The total KV cache space allocated.

Prometheus Rule Definition

First, define a PrometheusRule to calculate average request saturation over a sliding 1-minute window:

apiVersion: monitoring.coreos.com/v1
kind: PrometheusRule
metadata:
  name: vllm-scaling-rules
  namespace: vllm-serving
spec:
  groups:
    - name: vllm.rules
      rules:
        - record: job:vllm_requests_waiting:avg
          expr: avg(vllm:num_requests_waiting{namespace="vllm-serving"}) by (app)

KEDA ScaledObject Configuration

Next, configure KEDA (Kubernetes Event-driven Autoscaling) to scale out our deployment dynamically based on real-time prompt queue length.

apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
  name: vllm-keda-autoscaler
  namespace: vllm-serving
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: vllm-llama3-8b
  minReplicaCount: 2
  maxReplicaCount: 16
  cooldownPeriod: 300
  pollingInterval: 15
  advanced:
    horizontalPodAutoscalerConfig:
      behavior:
        scaleUp:
          stabilizationWindowSeconds: 0
          policies:
            - type: Percent
              value: 100
              periodSeconds: 15
        scaleDown:
          stabilizationWindowSeconds: 300
          policies:
            - type: Percent
              value: 10
              periodSeconds: 60
  triggers:
    - type: prometheus
      metadata:
        serverAddress: http://prometheus-k8s.monitoring.svc.cluster.local:9090
        metricName: job_vllm_requests_waiting_avg
        query: |
          sum(vllm:num_requests_waiting{namespace="vllm-serving", app="vllm-llama3-8b"})
        threshold: '5.0'

Scaling Logic: If the total number of waiting requests across the cluster exceeds 5.0, KEDA triggers an immediate aggressive scale-up (up to 100% capacity increase every 15 seconds), prompting Karpenter to provision new Spot instances instantly.


5. Cost Optimization and Benchmark Analysis

To validate this architecture, we ran a load test simulating real-world production traffic over a 72-hour test period.

Test Configuration

  • Model: Llama-3-8B-Instruct (FP16)
  • Instance Types: g5.2xlarge (1x NVIDIA A10G 24GB GPU)
  • Traffic Pattern: Variable load between 10 RPS and 180 RPS with intentional artificial spot disruptions injected every 4 hours via AWS Fault Injection Simulator (FIS).

Results Breakdown

| Metric | Pure On-Demand Baseline | Native Spot (No Interruption Handling) | Ecstaticloud Zero-Downtime Spot Arch | | :--- | :--- | :--- | :--- | | Hourly Operating Cost | $97.12 / hr | $29.13 / hr | $31.40 / hr | | Total Cost Reduction | Baseline (0%) | -70.0% | -67.6% | | Failed Requests (5xx Errors)| 0.00% | 4.82% | 0.001% (Recovered by Mesh Retry) | | P99 TTFT (Time-To-First-Token)| 82 ms | 3,420 ms (OOM/Interruption spikes) | 89 ms | | Successful Interruption Handling| N/A | 0% | 100% (24/24 Spot Evictions Drained)|

Cost Savings Summary

By combining 80% Spot Capacity with a 20% On-Demand baseline managed dynamically by Karpenter and KEDA, we cut our infrastructure costs by 67.6% while maintaining production P99 latency targets.


Technical Checklist for Production Deployment

Before pushing this architecture to production, run through this verification checklist:

  • [ ] Karpenter SQS EventBridge Integration: Confirm that aws.ec2 interruption events are routing correctly to the Karpenter SQS queue.
  • [ ] vLLM Graceful Shutdown: Verify that your custom preStop hook gives in-flight requests adequate time to drain before receiving a SIGKILL.
  • [ ] Cross-AZ Spreading: Ensure topologySpreadConstraints are active so an entire AZ Spot outage does not bring down your inference tier.
  • [ ] Warm Model Images: Use optimized AMI base layers with pre-cached Docker layers containing model weights or mount an Amazon EFS/S3 Mountpoint high-throughput file system to reduce cold start times below 45 seconds.
  • [ ] PodDisruptionBudgets (PDB): Enforce a PDB with minAvailable: 80% to ensure Karpenter consolidation doesn't tear down too many pods concurrently during low-traffic periods.

Summary

Scaling LLMs effectively requires rethinking traditional cloud architecture patterns. By treating GPU compute as ephemeral resources and relying on deep, application-level metrics (vllm:num_requests_waiting) rather than host-level CPU utilization, you can run demanding GenAI workloads reliably on Spot instances.

Using AWS EKS, Karpenter, vLLM, and KEDA, you can build a self-healing, auto-scaling cluster that automatically absorbs spot evictions with zero impact on end users—all while cutting your cloud expenses by over two-thirds.

Need Help Scaling Cloud Infrastructure?

Partner with Ecstaticloud's boutique engineering architects to implement zero-trust architectures, optimize inference workloads, or eliminate cloud waste.

Talk to an Architect
Deep Dives

Related Technical Insights

View all →