Skip to main content
This demo shows how the cluster’s routing and caching work together: when the cluster sees the exact same prompt more than once, the router tends to send repeated requests back to the pod that already cached that work. The scheduler and router favor saved computation because reusing cached prefill state is far cheaper than recomputing it. Key points covered here:
  • How fixed-size cache blocks affect prefix hits.
  • How to seed the cache and verify which pod served repeated requests.
  • How to query Prometheus to confirm per-pod prefix cache hits.

Cache block size and why prompt length matters

The key-value cache used by the model server stores cached prefill output in fixed-size blocks. On this cluster, a cache block is 128 tokens. Any prompt shorter than one block never fills a cache block, so repeated requests for such short prompts cannot produce prefix cache hits. Make sure your repeated prompt is long enough to occupy at least one cache block.
Cache hits are tracked per cached block. If your prompt does not fill a cache block (here, 128 tokens), repeated requests won’t trigger prefix cache hits.

Prepare a realistic repeated prompt

Save the long lead-in you plan to reuse as an environment variable so each request sends byte-for-byte the same text:
This ensures every request uses identical bytes, which is required for the cache lookup to match.

Check Prometheus before sending requests

Before you start, verify the prefix cache hit counters in Prometheus to confirm all pods begin at zero. The prefix cache metric in this example is exposed per pod; check it at your Prometheus instance:

Send the same request repeatedly through the router

The first request seeds the cache on whichever pod the router selects. Subsequent identical requests, if routed to the same pod, will hit cached blocks and skip the heavy prefill work. Run this loop to send the same prompt six times and print the model’s short text response each iteration:
Notes:
  • The first iteration is the cold request that seeds the cache on a pod.
  • Later iterations can produce prefix cache hits only if the router sends them back to the pod that seeded the cache.
  • The example uses jq to extract the returned text; adapt to your response schema if different.

Query Prometheus to see per-pod prefix cache hits

After the loop completes, run this PromQL query to sum prefix cache hits per pod over the last 5 minutes:
Use this table to map the query to its purpose: Example output (illustrative):

How to interpret the results

  • One pod’s hit counter jumped while the other pods remained at or near zero. This indicates the router consistently routed the repeated requests back to the pod that seeded the cache.
  • The pod with increasing hits avoided redoing the expensive prefill computation for repeated identical prompts, demonstrating the cost savings of reuse.
  • The very first request does not produce a hit — it was the cold request that populated the cache. Only subsequent requests generated prefix hits.

Caveats and takeaways

  • This experiment depends on traffic repeating the exact same bytes. If requests are different (for example, 30 distinct prompts), you will not observe per-pod prefix-hit effects because no cached prefix matches those requests.
  • Ensure your prompt length matches or exceeds the cache block size (128 tokens in this cluster) if you expect prefix cache hits.
  • Use Prometheus to monitor per-pod metrics and validate routing and caching behavior in production.
If your prompt is shorter than the cache block size, repeated requests will not generate prefix cache hits. Confirm tokenization length and block size before running this test.
This experiment demonstrates two things at once: the router honoring the policy to send repeated prompts to the pod that already has the cached prefix, and the cache reducing repeated work by serving requests from cached prefill blocks.

Watch Video