← Back to knowledge center

LLM prefix caching: measuring latency and capacity gains

When many requests open with the same long policy, the server can reuse intermediate computation. The benefit depends on matching prefixes, available memory, and actual traffic patterns.

V
Virtek AI and Infrastructure TeamCompute platform architecture

Look for shared prefixes

A prefix is the beginning of a token sequence. When a full block of tokens and its preceding blocks match, vLLM can reuse their cached key and value states. This reduces input processing, known as prefill. New output tokens are still decoded sequentially. Start with a workflow that has a stable prefix, such as a support assistant that receives the same policy and response schema in every session.

Compare three runs with the same workload

Run once without cache reuse, once with a warm cache, and once with a mix of fresh and repeated requests. Keep the prompts, model, tokenizer, concurrency, and output length distribution comparable. Collect p50 and p95 time to first token (TTFT), time between tokens, the share of reused input tokens, queue time, and KV cache utilization. Include a burst immediately after a restart.

Define who can share cached blocks

Decide which applications or tenants may share entries. The vLLM cache_salt request parameter limits reuse to requests with the same salt. Assign it at a trusted server according to access boundaries. Retain normal authorization and data access checks. After changing the model, prompt template, or tokenizer, repeat the measurements on the new configuration.

Use mixed traffic to make the decision

Set a p95 TTFT target and measure how much traffic the system can serve within it. Check how long novel prompts, block eviction, and traffic distribution among replicas affect the result. Compare with the baseline to decide whether caching, more serving capacity, or shorter inputs will meet the target.

Need an architecture
for your workload?

We will review inputs, risks and constraints, then propose a reasoned solution.

Talk to an engineer↗︎