KV Cache Routing The Cluster level Optimisation
KV cache routing preserves prefix-cache locality across inference replicas, reducing repeated prefill work when workloads reuse long shared contexts.
In the full article
Read the transcript
Auto-generated captions; wording may contain recognition errors.
Prefix caching is one of the most effective techniques for reducing inference cost on workloads that repeatedly send long shared contexts. The concept is straightforward at the single server level when multiple requests share the same prompt prefix. The key value tensors computed for that prefix [music] can be stored and reused rather than recomputed from scratch on every request. The savings scale directly with how long and how frequently shared the prefix is. The complexity emerges at the cluster level. And this is where most production deployments discover [music] that simply enabling prefix caching is not enough. A cluster of inference servers does not share a unified KV cache. [music] Each replica maintains its own GPU resident cache independently. A prefix cached on one server provides no benefit when the next request for that prefix is routed to a different server that has never seen it. [music] At scale, cache hit rates collapse unless the routing layer is aware of what each server has cached and directs traffic accordingly. KV cache aware routing solves this by making routing decisions based on cache state rather than simple load metrics like request count or Q depth. [music] Instead of routing an incoming request to the least loaded server, the router hashes the requests prefix [music] and queries which server in the fleet is most likely to have that prefix already cached. Requests are preferentially routed to the server where a cache hit is probable [music] and only fall back to load-based routing when no server has a useful cache state for that prefix. The practical consequence is significant. Two identical deployments running the same inference framework can have dramatically different effective costs [music] depending on whether the routing layer is cash aware or cash blind. A cachblind load balancer spreads requests evenly across servers, diluting cache locality and driving hit rates toward zero on workloads with shared prefixes. [music] A cache aware router concentrates similar requests on the servers that have already done the prefill work, capturing the cost reduction that prefix caching promises. Prefix cache hit rate is a workload specific metric rather than a single global number. Workloads with long stable shared system prompts, repeated document contexts, or common tool description blocks all benefit significantly from this approach. Workloads with entirely unique prompts on every request see no benefit regardless of whether routing is cash aware. Measuring [music] hit rate per workload type is therefore a prerequisite for knowing whether investing in cashaware routing infrastructure is justified for a given deployment.


