← Blog
Published on
2026-12-01

How to verify LLM prefix cache isolation on shared vLLM replicas

LLM prefix cache isolation determines whose requests can reuse the work of processing a prompt. With tenant salting enabled on a supported vLLM route, Hivenet Router v0.1.8 uses the authenticated API key’s owner as the cache boundary. Two applications whose keys have the same owner can reuse matching blocks while those blocks remain on the replica. Another customer using the same model and system prompt gets a separate cache namespace. On a shared service, cross-tenant cache reuse can disclose that another customer processed a particular piece of text. For a confidential system prompt, even that information can be sensitive. Enforcing the owner boundary lets an application keep using its own warm prefixes.

This guide is for operators who share vLLM capacity across customers. It walks through the configuration, the metrics to inspect on each Router, and a controlled check of POST /v1/chat/completions. The expected observations come from the release documentation. We did not run a shared-GPU deployment for this guide.

What does vLLM store in the prefix cache?

Imagine a support application that sends the same long system prompt before a different user question on every request. During prefill, the inference engine computes attention keys and values for the input tokens. The model weights stay the same across requests. The keys and values stored in the KV cache depend on the tokens and their preceding context. Automatic prefix caching lets vLLM reuse that KV cache for complete blocks of matching tokens at the start of a later request. The model still generates a new answer. A change to the user question at the end can leave the system prompt reusable. A change to even a single token at the beginning can break the match for every later block. For example, a timestamp inserted before the instructions makes two otherwise identical requests poor fixtures for testing reuse. See the vLLM automatic prefix caching guide.

Cache salting gives the inference engine an additional input when it builds a cache key. In Router, that input is a tenant-specific identifier derived from the authenticated owner. vLLM includes it as cache_salt when hashing the first block. Later block hashes depend on the preceding block, so the salt affects the whole prefix. Two tenants can submit identical input tokens to the same engine and get different cache keys from the first block onward. The separation is logical: the tenants still share GPU memory and processing capacity. See vLLM’s prefix cache design.

What changes for shared system prompts?

Suppose ten customers all use the same support template. With isolation enabled, each owner has to warm its own prefix the first time it reaches a replica. Later requests from that owner can reuse its blocks while they remain resident. Expect less reuse across the workload than in one global prompt cache. Whether that raises the cost per completed request depends on how often each customer repeats the prefix and how busy the server is.

Which tenant owns a cached prefix?

Take two applications belonging to a fictional customer, North, and a third belonging to South. With static keys, assign the first two the same metadata.owner in auth.yaml and the third a different owner. With dynamic keys, use owner. Give all three test keys access to the same concrete model. Router gets the tenant identity from the credential and supplies the salt itself. The application sends its ordinary chat request. Router removes any client-supplied cache salt and derives the value it forwards from the key’s owner and the site secret. Decide whether an owner represents an organization or an individual user. If a gateway sends every customer’s LLM request with one service credential, Router sees one owner. Separate browser sessions or user IDs in the JSON body do not split the cache. Give each intended trust group its own authenticated owner before testing.

Check how the agent registered and which API route the application calls. For the walkthrough, use a supported vLLM build at or above 0.27.0 and register the agent with --engine vllm. Use the SHA-256 prefix hash recommended by the Router documentation. Hivenet documents support for the vLLM messages route, /v1/messages, starting at 0.27.0. The native vLLM registration matters: Router v0.1.8 does not provide tenant cache isolation for a vLLM backend registered as a custom engine. Record the actual engine version from the operator routing table before testing. Check other engines and routes against the Router agent compatibility table.

Configure one cache-salt secret per site

Start every Router in the site with --multi-tenant. This mode enables cache salting by default, requires model allowlists, and hides agent identity from clients. Provision a dedicated random cache-salt secret of at least 32 bytes. Distribute the same secret to every Router serving the site. Keep it distinct from the agent JWT secret, the Valkey password, and the metrics credential.

The following options belong on the existing Router launch command. Replace the example paths and Valkey address with your deployment’s values. This example uses TLS to a password-protected Valkey service. Multi-tenant mode requires shared counters even in a single-Router site. Configure authenticated client and admin access, protect the metrics endpoint, and make sure the Router can write its audit log. See the multi-tenant startup requirements.

--multi-tenant \
--auth-config-file /etc/hivenet-router/auth.yaml \
--cache-salt-secret-file /etc/hivenet-router/cache-salt.secret \
--metrics-bearer-token-file /etc/hivenet-router/metrics.token \
--sync-store valkey \
--sync-valkey-addrs valkey:6379 \
--sync-valkey-password-file /etc/hivenet-router/valkey.password \
--sync-valkey-tls

Will rotating an API key empty the tenant’s cache?

On a supported route, a replacement key with the same owner maps to the same namespace while the site secret stays the same. Reuse still depends on the same replica holding the matching blocks. Rotating the site’s cache-salt secret has a different effect: it changes the namespace for every owner. Expect a cold prefix cache after that rotation and allow time for every Router to pick up the new secret before comparing results.

Read three signals before interpreting cache hits

Check fresh metrics for every expected Router instance. Confirm the scrape is succeeding and the test agent is registered. A dashboard with a missing instance can look healthy while telling you nothing about the requests that instance serves.

  • Is salting enabled? hivenet_cache_isolation_enabled should be 1 on each Router. This reports the Router’s setting. The backend still needs to honor the salt on the route in use.
  • Does a registered engine have a coverage gap? Read hivenet_cache_isolation_gaps by its model and engine labels. A positive value counts registered LLM agents with a generation route that lacks isolation. Inspect the warning for the engine version and affected route. An absent gap series on its own does not establish coverage.
  • Do the routers agree? A positive hivenet_cache_salt_secret_mismatch means a live peer reports a different salt setting or secret. Check the configured secret versions across the site. Peers compare fingerprints periodically, so a reading taken immediately after a rollout can precede the comparison.

These checks answer different questions. At startup, two routers with different secrets can both report salting enabled, yet give the same owner inconsistent cache reuse. A site can also agree on a secret while an agent serves a route that cannot use it. The Router metrics reference describes all three signals.

Verify reuse with synthetic traffic on one test replica

Use a fresh, operator-controlled test replica with automatic prefix caching enabled. Send all test requests to that replica through Router using non-streaming chat completions. This holds the destination constant: a request sent to a different GPU could miss simply because that GPU never served the first prompt. Enable --enable-prefix-caching and --enable-prompt-tokens-details on the test vLLM server. Use one fixed, non-sensitive fixture long enough to fill several cache blocks. Keep the messages, model, and chat template identical throughout.

  1. Warm North’s cache. Send the fixture with North’s first test key and let the response finish. Send it again with North’s second key. With the blocks still resident, expect the second response to report reused prompt tokens in usage.prompt_tokens_details.cached_tokens.
  2. Check South’s first request. Send the same fixture with South’s key. In this fresh test, South has no earlier requests. With usage reporting working, its first call should explicitly report zero cached prompt tokens. A missing or null count makes this observation inconclusive.
  3. Repeat as South. Send the fixture again with South’s key. A positive cached-token count now shows South can reuse its own blocks. This control matters: two customers who always get zero could simply be using a server with caching disabled.

For each call, save the Router’s X-Request-ID and the engine-reported count. Use the operator audit log to match request_id to tenant_id, key_id, and agent_id. Confirm the intended owners and the same agent across the sequence. Record the model, route, and Router and vLLM versions alongside the results. Keep the synthetic fixture in the test project. Request IDs and counts are enough to document the outcome without copying prompt text or credentials into a ticket. The audit field reference explains where to find those identifiers.

How do you interpret the cached-token count?

Read cached_tokens alongside usage.prompt_tokens. If two requests from the same owner share the start of a long conversation but end with different questions, the engine can report a partial hit while matching blocks remain on the replica. Each complete matching block saves prefill work. The engine processes the rest of the prompt and still performs each decode step for the new answer. Prefilling a long prompt is often compute-bound, while decoding at low batch sizes is often limited by memory bandwidth. Skipping some prefill can bring the first token forward even when the rest of a long answer takes just as long to generate. Keep output length comparable when you measure the latency cost of a cold prefix. See NVIDIA’s explanation of prefill and decode.

If cached_tokens is missing, record the result as unknown and check usage reporting. If neither owner gets a repeat hit, check the replica identity, prefix length, template consistency, and whether the blocks could have been evicted. If South’s first call reports a hit, establish that the test replica was fresh and inspect the owner assignments, engine registration, and route support before accepting the deployment. A faster first token alone cannot identify which cached blocks were reused.

Should a drop in cache hit rate block a production rollout?

A lower hit rate after enabling isolation can be the intended result. A template that used to be warm for the entire service must now be processed for each owner. For a performance check, use representative synthetic traffic, keep the serving configuration and concurrency fixed, and compare time to first token and completed requests per second. A lower hit rate means the engine recomputes more input tokens. On a prefill-heavy workload, compare the extra GPU time per completed request against the warm baseline to estimate any change in operating cost. Use the owner-level checks to decide whether the isolation works.

For the isolation check, read individual request records. For the performance check, divide the sum of cached prompt tokens by the sum of prompt tokens for requests with both fields present. Keep counts of missing records and group results by owner and replica before combining them. Otherwise a tenant that repeatedly sends one long document can dominate the service-wide result.

Does isolating the KV cache reserve GPU capacity?

The salt controls which blocks the inference engine can reuse. Long contexts and concurrent requests still compete for GPU memory on the same server. In a full-attention model, a longer sequence length means keeping more token positions in the KV cache. The bytes per position depend on the model architecture, including its attention layers and KV heads, and on the precision used for the cache. vLLM’s PagedAttention manages this state in fixed-size blocks. For a fixed model and cache precision, KV memory grows roughly linearly with the number of retained token positions, rounded to whole blocks. The salt changes which blocks match a request without changing their size. See the PagedAttention paper. Tenants still share the replica’s memory and queue. Under memory pressure, the engine can evict an unused block before its owner returns. A same-owner miss is therefore compatible with correct isolation.

A successful check covers the tested model, backend build, and API route. Repeat it after changing the engine, authentication mapping, or routes that customers can use. Tenants can still contend for GPU capacity. If you need to give one customer its own serving pool, see the dedicated replicas guide. If the question is which eligible replica should serve a returning conversation, the prefix-aware routing guide covers that decision.

Your next workload belongs on Hivenet.

Pick one AI, compute, or storage workload and see the difference for yourself. Spin it up in minutes, or let our team map your fastest path to production.