Skip to main content
← PROBLEMS / AI-SYSTEMS
An end-to-end domain learning journey

Design a Multi-Tenant LLM Inference Router
with Zero-Copy RadixAttention Prefix Caching.

Route requests via a Prefix-Aware Consistent-Hash Router keyed by (tenant_id, prefix_block_hash) to GPU Worker Pods running local RadixAttention + CPU-DRAM L2 KV offload.
Start the journey7 stages· Last modified Nov 22, 2026
FIRST PRINCIPLES. PRODUCTION SCALE.
The idea to keep with you

To keep the architecture evolvable without sacrificing reliability, random or round-robin load balancing destroys prefix cache hit rates across 64 GPUs; prefix-aware consistent hashing with bounded-load fallback preserves > 85% hit rates while preventing single-GPU hot spots.

TL;DR30-second simplified summary
▾

Hashing the salted prefix onto a consistent-hash ring keeps warm prefixes localized on specific H100s. Bounded-load checks (1.25x cap) prevent hot-GPU queuing.

Offloading evicted GPU pages to 512 GB CPU DRAM cuts reload latency 10x compared to cold prefill.

Before you begin · Building blocksAlready know these? Jump to Stage 01 ↓
AI/LLM Prefix Caching & RadixAttention (Zero-Copy KV Sharing)
RadixAttention indexes cached GPU KV-cache blocks in a compressed prefix trie (Radix Tree) with LRU eviction, enabling zero-copy prefix sharing across concurrent and sequential LLM requests.
Consistent Hashing & Virtual Nodes
Consistent hashing assigns data keys to servers in a way that limits how many keys move when servers are added or removed. This helps avoid widespread cache misses and sudden load on databases.
Disaggregated LLM Serving (Prefill vs. Decode Pools)
Disaggregated LLM serving separates prompt prefill (compute-bound TTFT) and autoregressive token decode (HBM-bandwidth-bound ITL) onto independent GPU pools, transferring computed KV-cache blocks over RDMA or NVLink without stalling in-flight decode batches.
Full walkthrough · 7 stages
01
STAGE 01 · COMPUTE & HBM MATHfoundation

Why Prefix Caching Is Mandatory at 2,000 Req/Sec.

Why this matters: Quantify why 2,000 req/sec on a 70B model requires RadixAttention prefix sharing to fit 8K-token prefixes in HBM.

Assume a 70B-parameter model (GQA, ~320 KB KV/token in FP16, or ~160 KB in FP8). An 8K-token prefix occupies 8,192 * 160 KB ≈ 1.3 GB per copy.

With 80% prefix sharing, RadixAttention stores that 1.3 GB once per active tenant/prompt instead of duplicating it per concurrent request, freeing 40+ GB HBM per GPU for higher batch sizes and cutting prefill compute by ~85%.

STAGE 01 · COMPUTE & HBM MATH

Why Prefix Caching Is Mandatory at 2,000 Req/Sec

2,000 Req / SecWorkload Scale8K Prefix = 1.3 GBHBM Bottleneck80% Shared Radix KVZero-Copy Reuse5x Lower PrefillFLOPsLatency SLAwith Radix

1.KV Memory Math: 8,192 tokens x 160 KB/token (FP8) = ~1.3 GB per prompt prefix.

2.Prefill Bottleneck: Recomputing 8K prefixes at 2,000 req/sec would saturate dozens of extra H100s on redundant prefill.

3.Sharing Multiplier: Storing one physical 1.3 GB Radix prefix per active pod lets hundreds of requests reuse it zero-copy.

RadixAttention shares 1.3 GB 8K-token prefixes zero-copy across requests, cutting prefill FLOPs 5x at 2,000 req/sec.

02
STAGE 02 · PREFIX-AWARE ROUTERfoundation

Consistent Hashing with Bounded Loads on `(tenant_id, prefix_hash)`.

Why this matters: Route requests by consistent hashing on (tenant_id, prefix_hash) with bounded-load spillover to protect pod queues.

At the API gateway/router, tokenize (or hash normalized UTF-8 chunks) of the leading K=512 tokens combined with tenant_id. Look up the target GPU pod on a consistent-hash ring.

Before forwarding, check the pod's real-time active_prefill_tokens telemetry: if overloaded (> 1.25x cluster average), walk clockwise on the ring to the secondary replica.

STAGE 02 · PREFIX-AWARE ROUTER

Consistent Hashing with Bounded Loads on `(tenant_id, prefix_hash)`

API GatewayPrefix KeyConsistent-Hash RingCache Affinityload <= 1.25 * avg?Hot-Key GuardTarget GPU WorkerOptimal Routechecks queue

1.Bounded-Load Routing: If the primary warm pod's queue exceeds 1.25x cluster average, spill to the next ring node.

2.Tenant Salt in Hash: Including tenant_id in the routing key prevents cross-tenant cache affinity probing.

3.512-Token Prefix Key: Hashing the first 512 tokens balances cache hit affinity with multi-turn conversation growth.

Consistent hashing with 1.25x bounded-load spillover preserves prefix cache affinity without overloading hot pods.

Engineering Decision Framework
Problem
How to implement Design a Multi-Tenant LLM Inference Router with Zero-Copy RadixAttention Prefix Caching without hitting unbounded tail latency, state divergence, or operational fragility.
Naive Solution
Use a single unpartitioned path with unbounded retries and synchronous global coordination.
Why It Fails
Global coordination serializes throughput under load, while unbounded retries amplify transient stalls into full outages.
Alternatives
Compare synchronous strict-consistency paths against bounded asynchronous replication, local caching, or partitioned ownership.
Engineering Decision
To keep the architecture evolvable without sacrificing reliability, random or round-robin load balancing destroys prefix cache hit rates across 64 GPUs; prefix-aware consistent hashing with bounded-load fallback preserves > 85% hit rates while preventing single-GPU hot spots.
Trade-Offs
Gains predictable p99 latency and fault isolation in exchange for explicit bounding, observability, and slightly higher implementation complexity.
Decision Exercise · Make the Call

When Design a Multi-Tenant LLM Inference Router with Zero-Copy RadixAttention Prefix Caching experiences a sudden 5x traffic spike alongside a slow downstream dependency, which engineering choice best protects system stability?

03
STAGE 03 · ROUTER LOGICintermediate

Implementing Tenant-Isolated Prefix-Aware Routing.

Why this matters: Implement PrefixAwareRouter.select_pod to hash (tenant_id, prefix) and walk the ring until a non-overloaded pod is found.

import hashlib

class PrefixAwareRouter:
    def __init__(self, ring, max_load_factor: float = 1.25) -> None:
        self.ring = ring
        self.max_load_factor = max_load_factor
STAGE 03 · ROUTER LOGIC

Implementing Tenant-Isolated Prefix-Aware Routing

(tenant_id, prefix)Router InputWalk Ring CandidatesCandidate Scanpod.load <=max_loadLoad GateLeast-LoadedFallbackSafe Selectionfilters

1.Deterministic Ring Walk: Walking the ring in deterministic clockwise order concentrates spilled traffic on warm backups.

2.No Infinite Loop: If every candidate exceeds max_load_factor, pick the least-loaded pod or shed with 429.

3.Sub-Millisecond Route: SHA-256 + binary search over ring vnodes executes in <50 microseconds.

Clockwise ring walking with 1.25x bounded-load checks keeps routing sub-millisecond and queues balanced.

04
STAGE 04 · WORKER KV TIERINGintermediate

GPU HBM Radix Tree + Async CPU DRAM L2 Cache.

Why this matters: Tier GPU HBM Radix Trees with async PCIe Gen5 offloading to a 512 GB CPU-DRAM L2 KV cache.

Each GPU worker runs a local Radix Tree over PagedAttention blocks. When HBM utilization crosses 85%, leaf nodes with ref_count == 0 offload asynchronously over PCIe Gen5 (~64 GB/s) to a 512 GB CPU-DRAM L2 pool.

Reloading an 8K prefix (1.3 GB) from CPU DRAM takes ~20 ms—over 10x faster than cold GPU prefill.

STAGE 04 · WORKER KV TIERING

GPU HBM Radix Tree + Async CPU DRAM L2 Cache

GPU HBM L1 (85%Cap)Tier 1 KVPCIe Gen5 Async DMABackground Evict512 GB CPU DRAM L2Tier 2 KVReload in ~20 ms15x Faster Hitstores pages

1.85% Watermark: Start background PCIe offloading at 85% HBM so active decodes never stall waiting for free pages.

2.16-Token Page Granularity: Fixed PagedAttention blocks transfer cleanly over pinned DMA buffers.

3.Leaf-First Eviction: Evict unreferenced leaf suffixes first, keeping shared system-prompt roots in HBM.

Async PCIe Gen5 offloading to 512 GB CPU DRAM retains 10x more KV prefixes and reloads 15x faster than recompute.

05
STAGE 05 · PREFILL-DECODE SPLITadvanced

Integrating RadixAttention with Disaggregated Prefill/Decode Pods.

Why this matters: Disaggregate Prefill and Decode pods so heavy 16K-token prefills never cause inter-token latency spikes on decode.

Think of Integrating RadixAttention with Disaggregated Prefill/Decode Pods as the intuition layer for Design a Multi-Tenant LLM Inference Router with Zero-Copy RadixAttention Prefix Caching: Disaggregate Prefill and Decode pods so heavy 16K-token prefills never cause inter-token latency spikes on decode.

At 2,000 req/sec, mixing 16K-token prefills with active decode batches causes inter-token latency (ITL) spikes. Route cache misses and partial suffix prefills to dedicated Prefill Pods (which own the Radix Tree), then RDMA/NVLink-transfer only the final KV blocks to Decode Pods for smooth token streaming.

STAGE 05 · PREFILL-DECODE SPLIT

Integrating RadixAttention with Disaggregated Prefill/Decode Pods

Prefill Pod PoolCompute-BoundRDMA / NVLink KVPushState HandoffDecode Pod PoolMemory-BoundFlat ITL < 20 msSmooth Streamstarts decode

1.Why Disaggregate: A single 16K-token prefill stalls all co-located decode streams for ~250 ms if run on the same GPU.

2.Prefill Owns Radix: Prefill pods maintain the Radix Tree and only transfer the active request's KV blocks to Decode.

3.Independent Scaling: Scale Prefill GPUs for TTFT and Decode GPUs for token throughput independently.

Disaggregating Prefill (Radix-owning) and Decode pods over RDMA eliminates prefill-induced decode jitter.

06
STAGE 06 · TENANT ISOLATIONadvanced

Enforcing Tenant Quotas & Zero Cross-Tenant Leakage.

Why this matters: Enforce zero cross-tenant leakage and noisy-neighbor isolation via salted Radix roots and per-tenant HBM quotas.

Think of Enforcing Tenant Quotas & Zero Cross-Tenant Leakage as the intuition layer for Design a Multi-Tenant LLM Inference Router with Zero-Copy RadixAttention Prefix Caching: Enforce zero cross-tenant leakage and noisy-neighbor isolation via salted Radix roots and per-tenant HBM quotas.

Salt every Radix Tree root with (tenant_id, model_version, lora_id) so cross-tenant hits are impossible. Pair global LRU with per-tenant HBM soft caps (e.g., max 25% of HBM per tenant) so a single tenant's 16K-token sweep cannot thrash other tenants' warm caches.

STAGE 06 · TENANT ISOLATION

Enforcing Tenant Quotas & Zero Cross-Tenant Leakage

Root Salt KeyHard IsolationPer-Tenant HBM CapQuota WallTenant-Scoped LRUFair CacheZero Timing LeakageSecurity Proofenforces

1.Side-Channel Closure: Salting every Radix root with tenant_id ensures Tenant B can never probe Tenant A's TTFT.

2.25% Soft Quota: One tenant flooding 32K-token prompts only evicts its own older leaves once above 25% HBM.

3.LoRA / Version Safety: Including model_version and lora_id prevents corrupt KV reuse across adapter switches.

Salted Radix roots and 25% per-tenant HBM caps eliminate timing side channels and noisy-neighbor cache eviction.

07
STAGE 07 · TELEMETRY & SCALINGadvanced

Scaling on Prefix Hit Rate, TTFT & KV Eviction Churn.

Why this matters: Track prefix hit ratio, TTFT p99, bounded-load spill rate, and graceful virtual-node draining during scale-in.

Think of Scaling on Prefix Hit Rate, TTFT & KV Eviction Churn as the intuition layer for Design a Multi-Tenant LLM Inference Router with Zero-Copy RadixAttention Prefix Caching: Track prefix hit ratio, TTFT p99, bounded-load spill rate, and graceful virtual-node draining during scale-in.

Monitor prefix_cache_hit_ratio, ttft_p99_ms, hbm_to_dram_offload_rate, and bounded_load_spill_rate. Use consistent-hash virtual-node draining during scale-in so only 1/N keys remap, and pre-warm newly added pods from a shared NIXL/RDMA KV store when traffic ramps.

STAGE 07 · TELEMETRY & SCALING

Scaling on Prefix Hit Rate, TTFT & KV Eviction Churn

prefix_cache_hit_r…Efficiency KPIttft_p99_ms < 200msLatency KPIbounded_load_spill…Balance SignalGraceful VnodeDrainDeploy Guardcorrelates

1.Spill-Rate Tuning: High bounded_load_spill_rate signals a hot tenant needs more vnode replicas or dedicated pods.

2.Graceful Scale-In: Drain departing pods' vnodes gradually so only 1/N prefixes cold-miss during autoscaling.

3.DRAM Offload Alert: Alert if PCIe offload bandwidth saturates, indicating HBM working set exceeded pod capacity.

Tracking prefix hit ratios, spill rates, and graceful vnode draining keeps multi-tenant TTFT fast during scaling.

Practice · Explain the consequences

Practice: Make the trade-off yourself.

Question 1 of 3
Score: 0/3

Why does standard round-robin load balancing ruin RadixAttention prefix cache hit rates across 64 GPUs?

Recommended Learning Flow