When KV Cache Is Slower Than Recomputing: The Hidden Cost in LLM Inference

    Caching is a reflexively trusted optimization in LLM inference engineering, but a shared KV cache in a large-scale MoE serving system unexpectedly increased p99 latency from ~3.96s to 17.3s despite median latency staying flat. This article analyzes why remote KV cache reads—small-object, high-frequency, serialized through a single shared store and placed on the critical path of synchronized context-parallel compute—can become a bottleneck that outweighs the cost of recomputation. It then presents four practical optimization principles: cache admission control based on recompute-vs-read cost models, read/write asynchronization with prefetch and fallback strategies, elastic scale-out and load balancing to eliminate single points, and an observability framework centered on tail latency. A key takeaway for inference engineers: a cache is only an accelerator if its read cost is meaningfully lower than the cost of recomputing the data it stores.

    A Counterintuitive Finding: Cache Made the System Slower

    In production LLM inference engineering, adding a cache is almost a reflex. One engineering team, while building an inference service for a very large mixture-of-experts (MoE) model, followed this instinct. To speed up long-context requests, they added a cross-instance shared KV cache to the system. The idea was straightforward: store the intermediate attention results (KV data) computed for previous requests, and reuse them when similar requests arrive, skipping the expensive recomputation.

    The measured results were surprising and unpleasant. After enabling the shared cache, median latency barely changed, but the slowest 1% of requests (p99 latency) jumped from roughly 3.96 seconds to 17.3 seconds—a fourfold degradation. The team eventually rolled back the feature entirely.

    The core lesson from this story can be summarized in a single sentence: reading from a cache has a cost, and that cost is often severely underestimated in system design. This article digs into that problem, breaks down why caches fail in LLM inference systems, and distills a set of reusable optimization principles.

    Background: What This Inference System Looks Like

    2.1 Storage Characteristics Imposed by the Model Architecture

    The model in question uses a low-rank compressed attention mechanism. Instead of storing a full key-value matrix for each attention head, it compresses each token’s key and value information into a single shared low-rank vector. The direct benefit is that, regardless of the number of attention heads, the amount of intermediate data that must be persisted per token is fixed and small. In low-precision storage (FP8), 256 tokens are packed into one data block, which is only about 12.4 MB—or roughly 48 KB per token.

    This means the cache’s granularity is small and the number of objects is very large. This is a key detail for understanding what follows: many small objects create a dramatically different I/O pattern for a storage system than a few large ones.

    2.2 Context Parallelism: The Synchronization Constraint of an 8-GPU Node

    The prefill stage for long context is computationally heavy, and a single accelerator cannot handle it alone. The system therefore uses context parallelism during prefill: a long input is split into chunks, distributed to multiple accelerators on the same node for parallel processing, and then the intermediate results are synchronized across all accelerators over the network so that each one ends up with the full context.

    This design imposes a hard constraint: all compute units on the same node are like interlocked gears—each step must wait for the others to sync. If a single GPU is waiting on a cache read, the other seven are idle. Any jitter at the tail is amplified into global latency by the synchronization barrier.

    2.3 Two-Level Cache Architecture

    The cache system has two tiers:

    • L1 (local cache): resides in the local memory of each inference instance, fast but capacity-limited, and only serves that instance.
    • L2 (shared cache): lives in a separate distributed key-value store, holds a much larger capacity, and is shared by all inference instances—a “public library” of KV data.

    The problem lies entirely at the L2 layer.

    Root Cause Analysis: Why the Cache Became the Bottleneck

    3.1 A Single-Point Shared Store Cannot Handle the Concurrency Peak

    L2 is a centralized service shared by all instances. During stable traffic, it performs well. But at peak times, eight compute units will almost simultaneously fire a large volume of cache read and write requests at the same storage backend. Because the data blocks are small and numerous, the request pattern becomes “high-frequency small packets.” Connection management, serialization, and network round-trip overhead are amplified sharply. Requests queue on the storage side, and latency develops a long tail.

    An analogy: a restaurant chain where each branch keeps its own small ledger (L1), but every transaction must also be recorded in a single corporate ledger (L2) at headquarters, and there is only one accountant. With light business, everything is fine. During peak hours, eight stores try to submit their ledgers at the same time, and everyone waits at the accountant’s desk.

    3.2 The Synchronous Execution Model Amplifies Storage Jitter

    As mentioned earlier, context parallelism requires all compute units to stay in lockstep. The cache read is placed on the critical path of computation: the subsequent compute steps cannot begin until the cached data is fetched. So a slow L2 response is not a small hiccup for a single request—it stops the entire node. The median latency stays unchanged because most requests either miss the cache or hit L1. The p99 spike, on the other hand, is the compound effect of a few requests colliding with L2 queueing.

    3.3 The “Hit Means Win” Assumption Does Not Hold

    Traditional cache design assumes that a hit is always faster than a miss. In LLM inference, this assumption needs to be reexamined. Under low-rank compressed attention, recomputing a cache block may cost only a few milliseconds. Fetching the same data from a remote shared store—including network transfer and queueing—may actually be slower. When the cost of reading the cache approaches or exceeds the cost of recomputing, the cache stops being an accelerator and becomes a liability.

    How to Optimize: Making the Cache a Real Accelerator

    Four general optimization principles can be distilled from the analysis above.

    4.1 Cache Admission Control: Only Cache What Is Expensive to Recompute

    Build a cost model that compares “recompute cost” with “read cost.” Only admit a data block into L2 if recomputing it is significantly more expensive than reading it. For data that is cheap to recompute, it is better to skip caching altogether. The admission decision can be made dynamically based on features such as prefix length and computation depth.

    4.2 Read/Write Asynchronization: Move the Cache off the Critical Path

    • Asynchronous writes: after computation completes, immediately move to the next step. Cache persistence happens in a background thread.
    • Read prefetch: initiate L2 reads in advance based on the request prefix, running in parallel with local computation. If the data arrives in time, use it; if a timeout is exceeded, fall back to recomputation.

    Prefetching requires a clear timeout and fallback policy: if the wait exceeds a threshold, abandon the cached result. Do not let the system’s overall latency suffer for the sake of waiting on a cache.

    4.3 Elastic Scaling and Load Balancing: Eliminate the Single Point

    The shared store should support horizontal scaling. Data should be partitioned and distributed across multiple storage nodes, and hot prefixes should be replicated to avoid making any single backend a queueing hotspot. In cloud environments, this layer can be built on general-purpose distributed cache and load-balancing services. For example, when building an inference platform on Baidu AI Cloud—or any comparable public cloud—you can leverage its distributed cache, object storage, and container orchestration offerings to build a multi-tier cache layer that scales elastically. Monitoring and alerting services should continuously track cache hit rates and tail latency metrics so that queueing degradation is caught early.

    4.4 Observation Focused on Tail Latency

    Looking at average latency alone will hide this class of problem. p99/p999 latency, cache read latency distribution, hit rate, and storage queue depth should be first-class monitoring metrics. Before enabling any caching feature, run a gray-release A/B comparison under realistic load. Let data—not intuition—decide whether to enable the feature at full scale.

    Conclusion

    This case is a valuable lesson for anyone building inference systems: a cache is not a free lunch; it is an architectural decision that must be justified with a cost model. Under new technology stacks such as low-rank attention and context parallelism, the cost balance between “recompute” and “read” has quietly shifted. Only by incorporating cache read/write overhead into the end-to-end latency model—combined with admission control, asynchronization, and an elastic architecture—can a cache return to being a genuine accelerator instead of a liability that drags the system down.