Radix Cache Explained: Prefix Reuse for Production LLM Serving

Radix cache for production LLM serving: which workloads gain, where gains collapse with KV pressure, the cross-tenant leakage risk, and what to check…

Radix Cache Explained: Prefix Reuse for Production LLM Serving
Written by TechnoLynx Published on 11 Jul 2026

A radix cache for production LLM serving pays off when many requests share long prompt prefixes and those prefixes fit in KV capacity. It stores the KV state of shared system prompts, few-shot examples and conversation history in a radix tree, so each new request recomputes only the part of its prompt nobody has seen before. On a single H100 NVL, the PrefixBench-H100 study (2026) measured a 5 to 6.5x reduction in time-to-first-token (TTFT) at an 8192-token shared prefix in both vLLM and TensorRT-LLM, and found the gain falling to a 5.6% hit rate and a 15.7x TTFT regression once the prefix working set reached 13.2 times the available KV capacity. Before enabling it, check three things: whether tenants can observe each other’s cache hits, whether your working set fits in KV memory, and what your arrival pattern does to reuse.

Why a radix tree fits KV-cache prefixes

A radix tree is a compressed trie: any node that is the only child of its parent is merged into the parent, so a single edge can carry a whole run of elements rather than one. That compression makes radix trees efficient for long strings and for sets of strings that share long prefixes.

The fit goes deeper than storage. The KV cache for a token depends only on the tokens before it, so two requests with an identical prefix can reuse the KV tensors of that prefix and skip computing them again. In SGLang’s RadixAttention, the tree maps token sequences to KV tensors held in a paged, non-contiguous layout with a page size of one token. A new request walks the tree along its longest matching prefix and computes only the unmatched suffix. In Preble’s global prefix trees, a node that matches a new request only in part is split into the matched part and the remainder.

Three mechanics matter in production, because they decide what survives under memory pressure:

  • Leaf-first LRU eviction. SGLang evicts the least recently used leaf first, so shared ancestors stay reusable until they become leaves themselves.
  • Reference counts. Under continuous batching, a node used by a running request cannot be evicted; each node counts its running users and becomes evictable only at zero.
  • One memory pool. SGLang does not reserve a fixed cache; cached tokens and running requests share the pool, and the system evicts cached tokens when it needs a larger batch.

The bookkeeping is cheap. On a ShareGPT benchmark with no reuse opportunities, the SGLang authors (Zheng et al., 2023) measured 0.2 seconds of tree management in a 74.3-second run, under 0.3% overhead, which is why they turn RadixAttention on by default. For how a radix cache works in practice, see what a radix cache is and where it cuts LLM inference latency; our explainer on how prefix reuse cuts LLM inference cost and latency walks the request path, and RadixAttention and its effect on inference cost across GPU clusters covers the SGLang implementation.

Which workloads gain the most from prefix caching?

Long shared prefixes followed by short outputs gain the most. Prefill is compute-bound and dominates first-token latency for long prompts, while decode is memory-bandwidth bound and dominates long generations. Prefix caching only removes prefill work, so the share of a request spent in prefill sets the ceiling on what it can deliver.

The common shapes are shared system prompts, templated retrieval-augmented generation, agent frameworks and multi-turn conversation. SGLang’s production deployment drew its cache hits from common system messages, frequently reused example images and multi-turn chat histories. Preble’s workload study (2024) found prompts 37 to 2494 times longer than generated outputs, with 85% to 97% of prompt tokens shared with at least one other prompt. Long-document question answering is a strong case: several questions against the same document produce large amounts of shared tokens and short answers. Few-shot evaluation can share at two levels at once, as on HellaSwag, where SGLang reused both the examples and the common question prefix across multiple choices.

The weak cases are just as clear. For long outputs with little sharing between chat sessions, decode time dominates and SGLang saw almost no speedup. Preble’s gains were smallest on programming, the workload with the longest decoding. Short prompts are a quieter trap: in a one-year production trace of 6.12 billion requests across 9,174 models (2026), even near-full cache hits on short-input requests removed little prefill work and barely moved TTFT.

Reuse in that trace was also bimodal: most requests reused either almost nothing or almost their entire prefix, and partial hits were rare. A fleet-wide average hit rate can therefore hide two populations that need different treatment.

How much radix caching speeds up serving, and where it stops

The measured gains are large inside a bounded regime. The SGLang paper reports up to 6.4x higher throughput and up to 3.7x lower latency across agent, reasoning, few-shot, JSON decoding, RAG and chat benchmarks. After a month in production, SGLang observed hit rates of 52.4% on LLaVA-Next-34B and 74.1% on Vicuna-33B, with first-token latency 1.7x lower on average for Vicuna-33B. Those numbers line up with the mechanism: a higher hit rate frees memory for larger batches and cuts prefill, so throughput rises and latency falls together.

PrefixBench-H100 adds the boundary. With reuse enabled, TTFT stays nearly flat as the prefix grows, while the reuse-off baseline scales almost linearly with prefix length. The same study measured energy per request falling 24% on TensorRT-LLM and 31% on vLLM. Its governing variable is the ratio of prefix working set to KV capacity: below parity, reuse is close to free; above it, hit rate drops sharply for both runtimes at once. The onset tracks that ratio rather than model size, and a capped 7B pool and a natural 32B pool reached the same eviction behaviour at comparable ratios.

The second finding is less obvious. While the working set fits, the large TTFT differences between runtimes come from the scheduler above the cache, not from the cache: cache effectiveness stayed within a couple of points across runtimes in every regime, while the leader on TTFT flipped with the arrival pattern. When a runtime comparison shows a big latency gap on prefix-heavy traffic, look at batch admission before blaming the cache.

The study states its own limits. Its steady-load runs used evenly spaced arrivals rather than Poisson traffic, and it did not test 70B-class models, multi-GPU serving or FP8 KV caches, all of which shrink per-device KV capacity and could bring the pressure regime on sooner. Anything that changes per-token KV size (grouped-query attention, multi-head latent attention, quantised KV) moves the working-set ratio, so a measured gain does not carry across model families. Benchmark against your own prefix population and arrival pattern.

Hybrid SSM models break plain prefix reuse

Hybrid models that mix attention with state-space layers do not get the same behaviour for free. Their recurrent layers update state in place, which rules out rolling a cache entry back to a partial overlap and leaves only exact-match hits. The Marconi authors (2024) measured that with a block size of 32, 25.0% of token blocks’ KVs were reused by later requests but only 0.4% of SSM states were. Their admission and eviction policies, which weigh compute saved per byte alongside recency, raised token hit rates 4.5 to 34.4x over vLLM and SGLang extended for hybrids and cut P95 TTFT by 36.1% to 71.1%. In Marconi’s layer-ratio microbenchmark, the three systems performed the same on a pure Transformer. Plain radix reuse is a Transformer assumption, so check the architecture before you count on it.

More than one replica: cache locality against load balance

With data-parallel replicas, each replica has its own KV pool, and without a cache-aware router repeated prefixes are recomputed on every replica. The production trace names the tension: sending related requests to the same host raises hit ratio but increases load imbalance, while spreading related requests across replicas duplicates the same prefix in several caches. In that trace’s simulations, a cache-first router (largest reusable prefix, falling back to least-loaded) paid 5% to 7% imbalance for its locality, and larger caches alone could not recover reuse when routing scattered session state. SGLang v0.4 (LMSYS, December 2024) added a cache-aware load balancer that keeps an approximate radix tree of each worker; on a benchmark of balanced long-prefix groups it raised hit rate up to 3.8x and throughput by up to 1.9x. When KV state is offloaded to host memory instead of evicted, reuse lasts longer, which our piece on hierarchical caching for low-latency LLM inference takes further.

Radix cache, PagedAttention block hashing and API prompt caching

All three reuse KV state for a shared prefix; they differ in granularity, who controls the cache and how long entries live. PagedAttention (Kwon et al., 2023) is the memory layer underneath: it splits each request’s KV cache into fixed-size blocks mapped through block tables, with reference counts and block-level copy-on-write so sequences can share physical blocks. vLLM’s automatic prefix caching builds on that layout by hashing each block together with its prefix and reusing blocks whose hashes match. Commercial prompt caching applies the same idea behind an API boundary.

  Radix cache (SGLang RadixAttention) Block-hash prefix caching (vLLM, TensorRT-LLM) API prompt caching (OpenAI, Anthropic)
Matching unit Token sequences on tree edges, page size of one token Full blocks only; partial blocks miss Exact match of the whole prefix up to a breakpoint
Default granularity One token 16 tokens in vLLM, 32 in TensorRT-LLM OpenAI: minimum 1,024 cacheable tokens on GPT-5.6 and later
Eviction or lifetime Leaf-first LRU, referenced nodes protected LRU on blocks Anthropic: 5-minute default, refreshed on use, 1-hour option; OpenAI: stored state kept for at most 24 hours (no default lifetime stated)
When reuse starts Once the prefix is in the tree TensorRT-LLM: after the originating request finishes Anthropic: after the first response starts
Isolation default Left to the serving system; absent or only partial in the surveyed systems vLLM: opt-in per-request cache_salt Never shared across organisations
You control Eviction and scheduling policy Block size, salt, offload Prefix order and breakpoints

Is prompt caching the same as KV caching? In the APIs it is KV caching over a prefix: the provider keeps the KV tensors, not the prompt text. What you gain is a price signal: OpenAI discounts cached input by up to 95%, and Anthropic charges 25% more than base input for 5-minute cache writes. The practical rule for APIs is to put stable content first and dynamic content last, because a single changed token before a breakpoint breaks the match.

Can a shared prefix cache leak one tenant’s prompt to another?

Yes, and the attack has been demonstrated. A cache hit is observably faster than a miss, so a shared prefix cache can reveal that another tenant sent the same prefix. The PromptPeek attack (NDSS 2025) recovered other users’ prompts against SGLang’s radix cache with an average 99% success rate in fully or partially reversing the input, on Llama2-13B on an A100. It exploits longest-prefix-match scheduling, which serves a request first when its match is longer by even one token. In vLLM, the advisory for CVE-2025-46570 measured that an attacker could distinguish cache hits from misses with an AUC of 0.571 on a 1-token prefix and 0.99 on an 8-token prefix. If a cached system prompt or user prompt is sensitive, that channel lets an attacker sharing the backend verify guesses at it.

The controls fall into three groups:

  • Partition the namespace. vLLM injects an optional per-request cache_salt into the first block’s hash, so only requests with the same salt reuse each other’s blocks, which allows sharing inside a trust group and isolates everyone else. OpenAI’s per-customer prompt_cache_key separates cache accounting and helps prevent cache-hit probing across customers.
  • Tag visibility per node. SafeKV (2025) tags every radix node with a private flag and creator ID and checks visibility at each hop, so cross-tenant access is blocked even where private and shared prefixes overlap.
  • Close the observation channel. The PromptPeek authors recommend modelling the full KV-cache lifecycle, hiding cache activity from clients and controlling client API parameters and request volume.

Isolation is not free. SafeKV measured full cache partitioning raising TTFT by 2.3% to 8.9% on Llama-2-13B and by 8.3% to 38.9% on Llama-2-70B under realistic cross-user overlap. Where tenants share a system prompt but not user content, whether to share the system prompt and isolate everything after it is a design choice to make on purpose, not a default to inherit. Hash quality matters too: vLLM warns that a non-cryptographic hash raises collision risk that can leak private information in multi-tenant setups, and moved to sha256 by default as of v0.11. Tenant separation is one of the duties covered in our guide to generative AI governance and risk for production use.

Checklist before enabling prefix caching in production

Run these checks against your own traffic before switching prefix caching on.

Check Why it matters
Who shares the cache, and can they see TTFT? Hit/miss timing is enough to reconstruct prompts; set salts or per-node visibility tags per trust group.
Prefix working set against KV capacity Gains hold below parity and degrade with over-subscription.
Prompt-to-output ratio and input length Short prompts and long outputs gain little.
Arrival pattern and first-request delay TensorRT-LLM reuses state only after the originating request finishes, so a burst of simultaneous requests may get no reuse; with four prefixes, that delay amortised within the first burst in PrefixBench-H100.
Reuse window In the 2026 production trace, about half of repeat requests from a user and model arrived within 0.1 seconds and around 80% within 10 seconds.
Block size Larger blocks help kernel efficiency but reduce reuse, because only full blocks are shared.
Routing across replicas Without cache-aware routing, replicas recompute and duplicate prefixes.
Model architecture Hybrid SSM layers allow only exact-match hits.
Eviction policy Simple FIFO and LRU often matched or beat web and storage cache policies on LLM prefix workloads.
Metrics Track cached tokens over total input tokens per user or workspace, plus latency and cost, before and after.

Log hit rate, evictions and TTFT per tenant and per prefix group rather than as one fleet number; with bimodal reuse, the aggregate tells you little about where a regression came from. TTFT itself mixes queueing, prefill, prefix lookup and scheduler delay, so a change in it does not say which component moved.

Bringing in help for prefix-caching work

TechnoLynx’s generative AI R&D team profiles the serving path, prefix caching included, when a production feature hits cost or latency pressure. TechnoLynx audits the serving stack, caching included, for cost and latency improvements before recommending model replacement.

The number to measure first is your own working-set ratio

PrefixBench-H100 measured its large gains with the prefix working set inside KV capacity, and its collapse came once the working set left it. That ratio is set by your prompts, model, KV precision and replica count, so no benchmark can tell you where you sit on it. Measure it before you rely on the cache, and measure it again whenever any of those inputs changes, because the cache shows nothing wrong until hit rates start falling.

Back See Blogs
arrow icon