Back to Community & Earn Hub

KV-Cache Prefix Sharing Across Multi-Tenant vLLM Clusters: Implementing LMCache + Redis L2 Offloading for 5x Higher Throughput

@sneha_patel7 hours ago·2 min read 1940 views
KV-Cache Prefix Sharing Across Multi-Tenant vLLM Clusters: Implementing LMCache + Redis L2 Offloading for 5x Higher Throughput

The Single-Node Trap of Built-In Prefix Caching

vLLM's Automatic Prefix Caching (--enable-prefix-caching) dramatically accelerates multi-turn agent loops—as long as every request lands on the exact same GPU pod.

In production Kubernetes clusters behind a round-robin load balancer:

  • Turn 1 hits vLLM Pod A -> computes the 32,000-token system prompt + codebase context (3.1s TTFT).
  • Turn 2 hits vLLM Pod B -> Pod B's local HBM cache is cold -> recomputes all 32,000 tokens from scratch!
  • When Pod A scales down or evicts idle blocks after 30 seconds of burst traffic, all cached KV tensors vanish.

Architecture: Shared L2 KV-Cache Fabric with LMCache + Redis

By attaching LMCache as a vLLM KV-connector backed by a high-throughput Redis (or Mooncake/Valkey) cluster, any vLLM replica can fetch precomputed KV tensors over 100Gbps VPC networking faster than recomputing attention prefill on GPU:

text
┌────────────────────────┐         ┌────────────────────────┐
│      vLLM Pod A        │         │      vLLM Pod B        │
│   (HBM L1 KV Cache)    │         │   (HBM L1 KV Cache)    │
└───────────┬────────────┘         └───────────┬────────────┘
            │ Write KV Chunks                  │ Fetch KV Chunks (~180ms)
            └──────────────────┬───────────────┘
                               ▼
              ┌─────────────────────────────────┐
              │   LMCache L2 Redis / Valkey     │
              │ (Content-Addressed Chunk Store) │
              └─────────────────────────────────┘

Each 256-token block is hashed by its prefix token sequence (sha256(prefix_tokens)), making KV sharing completely stateless across pods.


Production Deployment Configuration

Enable LMCache in your vLLM server configuration using lmcache_config.yaml:

yaml
# lmcache_config.yaml
chunk_size: 256
local_cpu: true
max_local_cpu_size: 16.0          # 16 GB host DRAM L1.5 cache
remote_url: "redis://redis-kv-cluster.internal:6379"
remote_serde: "naive"             # Zero-overhead raw FP16 tensor serialization
pipelined_backend: true

Launch vLLM pointing to the shared KV connector:

bash
export LMCACHE_CONFIG_FILE="/etc/vllm/lmcache_config.yaml"

python3 -m vllm.entrypoints.openai.api_server   --model Qwen/Qwen2.5-Coder-32B-Instruct   --enable-prefix-caching   --kv-transfer-config '{"kv_connector":"LMCacheConnectorV1","kv_role":"kv_both"}'   --gpu-memory-utilization 0.90

Production Benchmarks (32k Token Context, 4x H100 Replicas)

  • Round-Robin Without Shared KV: Median TTFT 3,120ms, 14 req/s cluster throughput.
  • LMCache + Redis L2 Shared KV: Median TTFT 195ms (16x faster TTFT), 68 req/s cluster throughput.

Shared L2 KV caching turns stateless Kubernetes autoscaling and high-context agent loops from mortal enemies into a unified, scalable fabric.

2 Comments

Discussion

@rohan_mehta7 hours ago

195ms TTFT across stateless Kubernetes replicas on a 32k context prompt is massive. Before LMCache, teams had to implement sticky session routing at the ingress layer—which completely broke autoscaling whenever one pod got pinned with heavy long-context tenants.

@siddharth_rao7 hours ago

Setting pipelined_backend: true and local_cpu: true as a 16GB L1.5 tier in host DRAM gives the best of both worlds—sub-millisecond host-to-GPU DMA for hot prefixes and Redis L2 fallback across pods.

Join the developer discussion

Sign in or create a free account to comment (+10 pts) and tag helpful AIStoreHub repositories.