Deploying Large Language Models (LLMs) in production presents a stark economic reality: GPUs are expensive, and traffic is unpredictable.
If you run an AWS g5.2xlarge instance (1x NVIDIA A10G) 24/7 to serve an internal model or an application with business-hours traffic, you pay approximately $885 per month per node—even when the system sits completely idle overnight and on weekends. Multiply this across dozens of specialized models, fine-tuned adapters, or multi-tenant architectures, and idle GPU expenditure quickly becomes the largest line item on your cloud bill.
Standard Kubernetes Horizontal Pod Autoscaler (HPA) natively struggles with this problem. HPA requires at least one replica running (minReplicas: 1) to gather pod-level CPU or Memory metrics. Furthermore, standard GPU utilization metrics reported by the NVIDIA Data Center GPU Manager (DCGM) are notorious for scaling down prematurely during quiet pauses in stream generation or failing to scale up before request queues backlog.
At Ecstaticloud, we engineered a zero-scale LLM inference pipeline on Kubernetes using vLLM, KEDA (Kubernetes Event-driven Autoscaling), and Karpenter. This architecture scales GPU workloads to absolute zero ($0/hr idle cost) when traffic drops, while maintaining sub-second inference speeds when warm and managing cold starts predictably.
Here is how we built it.
Architecture Blueprint: Zero-Scale Infrastructure
To scale a GPU workload down to absolute zero replicas and zero nodes, the architecture must separate the ingress traffic queue from the execution layer. When the replica count hits zero, no pods exist to collect metrics. Therefore, the autoscaler must inspect an external queue, ingress buffer, or metric exporter.
[ Incoming Inference Requests ]
│
▼
[ Envoy / Ingress Gateway ]
│
┌──────────────┴──────────────┐
▼ ▼
[ Prometheus / Metrics ] [ Request Buffer / Queue ]
│ │
▼ │
[ KEDA Operator ] │
│ │
(Triggers Scale-Up when > 0) │
│ │
▼ ▼
[ vLLM Pod (0 -> 1) ] ◄────────────────┘
│
▼
[ Karpenter Node Provisioner ]
│
▼
[ AWS EC2 g5.2xlarge Node ]
Key Components
- vLLM: High-throughput LLM serving engine powered by PagedAttention, which optimizes Key-Value (KV) cache memory management and yields up to 24x higher throughput than standard Hugging Face Transformers pipelines.
- KEDA (Kubernetes Event-driven Autoscaling): Drives the scaling behavior of the vLLM
Deployment. It probes external metrics (Prometheus request rates or queue depth) to scale the deployment from 0 to N and back to 0. - Karpenter: An open-source, high-performance Kubernetes node provisioner. When KEDA scales the vLLM deployment from 0 to 1, the newly created pod sits in a
Pendingstate due to unsatisfied GPU resource requests (nvidia.com/gpu: 1). Karpenter intercepts this unschedulable pod and provisions an EC2 GPU instance within ~30–45 seconds. Conversely, when KEDA scales the deployment to 0, Karpenter immediately cordons and terminates the underlying GPU node. - Shared High-Performance Cache (NVMe / EFS): Solves the model weight loading bottleneck during cold starts.
Step 1: Configuring vLLM with Local HostPath & Model Caching
Downloading a 14GB–30GB model binary from Hugging Face Hub during every cold start can destroy your tail latency, adding 3–5 minutes of network transfer delay. To eliminate this, we pre-cache base models onto a shared high-performance storage layer or leverage local instance NVMe drives backed by pre-baked Amazon Machine Images (AMIs).
Below is the optimized vLLM Kubernetes deployment configuration utilizing zero-copy model loading via safetensors:
apiVersion: apps/v1
kind: Deployment
metadata:
name: vllm-mistral-7b
namespace: llm-inference
labels:
app: vllm-mistral-7b
spec:
replicas: 0 # Default state managed by KEDA
selector:
matchLabels:
app: vllm-mistral-7b
template:
metadata:
labels:
app: vllm-mistral-7b
spec:
containers:
- name: vllm-container
image: vllm/vllm-openai:v0.6.3
args:
- "--model"
- "mistralai/Mistral-7B-Instruct-v0.2"
- "--port"
- "8000"
- "--max-model-len"
- "4096"
- "--gpu-memory-utilization"
- "0.90"
- "--tensor-parallel-size"
- "1"
env:
- name: HUGGING_FACE_HUB_TOKEN
valueFrom:
secretKeyRef:
name: hf-token-secret
key: token
- name: HF_HOME
value: "/pv-cache/huggingface"
ports:
- containerPort: 8000
name: http
resources:
limits:
cpu: "8"
memory: "32Gi"
nvidia.com/gpu: "1"
requests:
cpu: "6"
memory: "24Gi"
nvidia.com/gpu: "1"
readinessProbe:
httpGet:
path: /health
port: 8000
initialDelaySeconds: 15
periodSeconds: 5
volumeMounts:
- mountPath: /pv-cache
name: model-cache
volumes:
- name: model-cache
hostPath:
path: /mnt/karpenter/nvme-cache
type: DirectoryOrCreate
Step 2: Provisioning Just-in-Time Compute with Karpenter
Standard Kubernetes Cluster Autoscaler updates Auto Scaling Groups (ASGs), which can take 2–4 minutes to evaluate pending pods and launch node groups. Karpenter bypasses ASGs and directly calls AWS EC2 Fleet APIs to provision exact-fit instances in under 45 seconds.
We define a Karpenter NodePool configured specifically for GPU instances, allowing nodes to collapse to zero when empty:
apiVersion: karpenter.sh/v1beta1
kind: NodePool
metadata:
name: gpu-node-pool
spec:
template:
spec:
requirements:
- key: karpenter.sh/capacity-type
operator: In
values: ["on-demand", "spot"]
- key: node.kubernetes.io/instance-type
operator: In
values: ["g5.xlarge", "g5.2xlarge", "g5.4xlarge"]
nodeClassRef:
apiVersion: karpenter.k8s.aws/v1beta1
kind: EC2NodeClass
name: gpu-node-class
disruption:
consolidationPolicy: WhenEmpty
consolidateAfter: 30s # Rapid deprovisioning after pods hit zero
---
apiVersion: karpenter.k8s.aws/v1beta1
kind: EC2NodeClass
metadata:
name: gpu-node-class
spec:
amiFamily: AL2
blockDeviceMappings:
- deviceName: /dev/xvda
ebs:
volumeSize: 100Gi
volumeType: gp3
iops: 3000
throughput: 125
userData: |
#!/bin/bash
# Pre-mount local NVMe ephemeral drives for zero-latency vLLM model caching
mkfs.ext4 /dev/nvme1n1 || true
mkdir -p /mnt/karpenter/nvme-cache
mount /dev/nvme1n1 /mnt/karpenter/nvme-cache
subnetSelectorTerms:
- tags:
karpenter.sh/discovery: ecstaticloud-eks-cluster
securityGroupSelectorTerms:
- tags:
karpenter.sh/discovery: ecstaticloud-eks-cluster
Step 3: Event-Driven Scaling with KEDA
To achieve scale-to-zero, KEDA uses a ScaledObject pointing to an external metric source. In our architecture, we measure either:
- Active HTTP connection rates on the Ingress Gateway (e.g., Envoy/Prometheus metric
envoy_cluster_upstream_rq_active). - Outstanding request metrics exported directly by an intermediate buffer queue (e.g., Redis, RabbitMQ, or NGINX queue metrics).
When the metric threshold > 0, KEDA instantly overrides the Deployment spec replicas from 0 to 1.
KEDA ScaledObject Deployment
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: vllm-keda-autoscaler
namespace: llm-inference
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: vllm-mistral-7b
minReplicaCount: 0 # Scales workload to complete zero
maxReplicaCount: 5
cooldownPeriod: 300 # Wait 5 minutes of total silence before scaling down
pollingInterval: 15 # Metric poll resolution
advanced:
horizontalPodAutoscalerConfig:
behavior:
scaleDown:
stabilizationWindowSeconds: 300
policies:
- type: Percent
value: 100
periodSeconds: 15
triggers:
- type: prometheus
metadata:
serverAddress: http://prometheus-k8s.monitoring.svc.cluster.local:9090
metricName: vllm_request_backlog
query: |
sum(rate(nginx_ingress_controller_requests{upstream="llm-inference-vllm-mistral-7b-8000"}[1m]))
threshold: '0.05' # Scale up if traffic > ~3 requests/min
Taming Cold-Start Latency: The Optimization Matrix
The primary trade-off of scale-to-zero AI architecture is Cold Start Latency. If an HTTP request arrives when the system is at zero replicas, the user request must wait for:
- KEDA Scaling Event Detection: ~5–15 seconds
- Karpenter EC2 Node Provisioning: ~30–45 seconds
- Container Pull & Initialization: ~10–20 seconds (with pre-warmed container images)
- Model Weight Loading into GPU VRAM: ~8–12 seconds (with local NVMe
safetensors)
Total un-optimized cold start latency can reach 80–120 seconds. For synchronous APIs, this will result in client timeouts. At Ecstaticloud, we implemented three optimization strategies to compress this window down to < 35 seconds total and handle it gracefully at the application layer.
Cold Start Breakdown (Unoptimized vs Optimized)
─────────────────────────────────────────────────────────────────────────────
Unoptimized [░░░░░ 120s ░░░░░]
│ Pull Image (40s) │ Launch Node (45s) │ Download Weights (25s) │ Init (10s) │
Optimized [▒▒ 32s ▒▒]
│ Karpenter Node Launch (22s) │ Local NVMe Model Load (7s) │ vLLM Init (3s) │
─────────────────────────────────────────────────────────────────────────────
1. Fast Model Loading via Safetensors and Shared Flash Drives
Avoid loading raw PyTorch .bin weights. Using safetensors allows direct memory mapping (mmap) straight from storage to system RAM to GPU VRAM, circumventing CPU deserialization overhead.
2. Async Queue-Based Ingress Pattern
For non-latency-critical batch pipelines, wrap the inference layer in an asynchronous request-reply architectural pattern (using Celery, Redis, or SQS). The API Gateway immediately responds with a 202 Accepted status along with a tracking ID, while KEDA monitors the queue length and scales vLLM instances in the background.
3. Progressive Edge Buffering for Synchronous Endpoints
When scaling synchronous chat applications:
- Use an NGINX or Envoy proxy configured with
proxy_read_timeout 120s;and HTTP/2 Server Sent Events (SSE). - Return an immediate metadata header to start streaming whitespace, keep-alives, or status pingframes (e.g.,
{"status": "allocating_gpu_resources"}) back to the client while the underlying vLLM container boots.
Production Financial Metrics & Cost Reduction Analysis
To analyze the ROI of Zero-Scale AI, we ran a 30-day comparative benchmark in a staging environment simulating typical corporate utilization: high demand between 08:00–18:00 Monday–Friday, with minimal activity over evenings and weekends.
| Metric | Always-On Architecture | Zero-Scale Architecture (KEDA + Karpenter) |
| :--- | :--- | :--- |
| Instance Type | AWS g5.2xlarge (1x A10G 24GB) | AWS g5.2xlarge (1x A10G 24GB) |
| Running Hours / Month | 720 Hours | ~240 Hours |
| Compute Cost ($1.212/hr) | $872.64 | $290.88 |
| Idle GPU Utilization | ~70% of time spent at 0% GPU utilization | 0% idle compute wastage |
| P99 Inference Latency (Warm) | 42 ms / token | 42 ms / token |
| Cold Start Latency | 0 ms (Always running) | ~32s (Only on first off-peak request) |
| Total Monthly Cost Savings | Baseline | 66.6% Savings |
By eliminating the baseline idle tax, overall infrastructure expenditures dropped by 66%, saving hundreds of dollars per deployed model every month.
Operational Best Practices
- Set Adequate Cooldown Windows: Avoid "flapping" (rapidly scaling up and down) by configuring a conservative
cooldownPeriod(e.g., 300 seconds) in yourScaledObject. This ensures that consecutive back-to-back requests during active user sessions do not trigger repeated cold starts. - Pre-warm Container Images: Use specialized node AMIs pre-loaded with large standard container layers (CUDA libraries, PyTorch runtime, vLLM binaries) so Karpenter instances only need to pull the application-specific code.
- Use Spot Instances carefully: While Spot instances offer an additional 60–70% cost reduction, unexpected interruptions during long streaming operations can degrade user experience. Restrict Spot usage to asynchronous batch processes, and rely on On-Demand instances for synchronous endpoints.
Conclusion
Scaling LLMs efficiently requires rethinking classical Cloud Native patterns. By shifting from standard resource metrics (CPU/Memory) to event-driven triggers with KEDA, pairing them with vLLM’s high-performance engine, and leveraging Karpenter for rapid node lifecycle management, you can eliminate idle GPU waste entirely.
Zero-scale AI allows cloud architecture teams to deploy dozens of micro-sized, domain-specific language models simultaneously without scaling baseline costs linearly—delivering enterprise-grade AI features at a fraction of traditional infrastructure expenses.