The Underestimated Cost of Read Caching: Why Cache Can Become the Bottleneck
This article examines a counterintuitive MoE inference optimization case in which enabling a shared cache left median latency unchanged but pushed p99 latency from about 4 seconds to about 17 seconds. It breaks down the fixed and tail costs of remote read caching, explains how a centralized L2 KV cache can create queueing and synchronization amplification, and presents practical mitigation patterns such as batch aggregation, asynchronous prefetch, locality-aware routing, admission control, sharding, backpressure, and cost-aware observability.
1. The Phenomenon: Cache Made the System Slower at the Tail Instead of Faster
In inference systems, “add a cache” is almost a reflex. If the same context or similar requests are likely to be processed repeatedly, storing intermediate results and reusing them next time seems like an obvious way to save computation. But during an optimization effort for a very large Mixture-of-Experts (MoE) inference service, the engineering team encountered a counterintuitive result: after enabling a shared cache, median latency was almost unchanged, while the slowest 1% of requests jumped from about 4 seconds to about 17 seconds. The feature was eventually rolled back entirely for a period.
The lesson is not that caching is useless. The important point is that reading from a cache also has a cost. When the computation saved by cache hits cannot cover the fixed overhead of lookup, transfer, queueing, serialization, and synchronization waits, the cache stops being an acceleration layer and becomes a new bottleneck layer. Worse, this cost often does not show up in average latency. It concentrates in tail metrics such as p99.
To understand the problem, we first need to look at the system structure. The service ran on an inference node with eight high-end accelerators. The model used a Mixture-of-Experts architecture and compressed key-value information through Multi-head Latent Attention (MLA): the amount of intermediate data that needed to be stored per token was relatively small. Data was organized in blocks, with one block covering hundreds of tokens. A single block was on the order of tens of MB, equivalent to only tens of KB per token. Long-text processing also used prefill context parallelism, splitting a long context across multiple accelerators for parallel processing. After processing, the accelerators had to communicate and synchronize to obtain the full context.
This means the eight compute units inside the node operated like tightly meshed gears: every step required synchronization, and if one link slowed down, the other units had to wait. The cache system had two layers: L1 sat close to the compute units in local memory, offering speed but limited capacity; L2 was a remote distributed KV cache with larger capacity that could be shared by multiple inference engines. The problem was in L2: it was like a central ledger shared by all stores. Capacity and sharing brought benefits, but also centralized read/write pressure.
2. Deconstructing the Read Cache Path: Where the Cost Goes
To decide whether a cache is worthwhile, it is not enough to ask “how much computation does a hit save?” You also need to ask “how much fixed cost does every lookup incur?” A remote cache read typically includes the following stages:
- Request construction and index lookup: Generate a cache key based on request characteristics, context block ID, model version, precision format, and other factors, then query metadata. Inconsistent metadata or overly fine-grained indexes increase the number of queries.
- Network round trips: Local memory access is on the nanosecond-to-microsecond scale, while remote cache access goes through the network stack, connection management, queueing, and retries. Even if a single round trip is short, it is amplified on the synchronous call path.
- Serialization and deserialization: The cache stores block-level intermediate data. After reading, the data must be deserialized, validated, and copied into memory accessible to the compute units. The larger the data block, the more noticeable the copy and validation cost.
- Concurrency control and queueing: When multiple inference engines share the same cache layer, hot keys, connection counts, and shard skew can all cause queueing. Centralized caches are especially prone to head-of-line blocking, where all requests pile up at the same entry point.
- Hit rate and invalid reads: If cache keys are designed too strictly, the hit rate is low, and the system pays the lookup cost before falling back to computation. If keys are designed too broadly, consistency risks may appear. Invalid reads become pure overhead.
- Synchronization amplification: In prefill context parallelism, one slow request can hold up multiple compute units on the same node. The tail latency of a cache lookup does not affect only a single request; it can spread to an entire group of requests through synchronization.
Putting these costs together reveals a key inequality: cache net benefit = computation time saved by hits - fixed lookup and movement cost - tail amplification cost. When fixed costs are high, hit rates are insufficient, and request locality is weak, the net benefit can easily become negative. Median latency may stay flat because some requests hit the cache, but p99 can be dragged down by queueing and synchronization amplification.
3. Root Cause: L2 Turned “Sharing” into “Centralized Queueing”
From a system-structure perspective, L2 was designed for large capacity and cross-engine sharing, but it naturally tends to become a centralized bottleneck. When multiple inference engines read and write the same remote cache layer at the same time, without batch aggregation, shard routing, and backpressure control, the result resembles “multiple stores all asking the same accountant to close the books”: each store’s local ledger is fast, but there is only one entry point to the general ledger. The busier the business, the longer the queue.
A more subtle issue is that cache benefits are usually evaluated by hit rate, while cache costs occur on every access. Suppose the hit rate is 60%, which looks reasonable. But if every miss must still query the remote cache first, then 40% of requests bear the cost of an invalid lookup. If the query timeout is long, missed requests also wait on the critical path. For long-text inference, a single request contains many blocks, so block-level lookups are amplified, making p99 more likely to deteriorate.
In addition, cache block granularity, admission policy, and request routing all affect the outcome. If all requests are randomly sent to arbitrary nodes, cache locality is poor and the L2 hit rate is low. If hot blocks concentrate on a few shards, shard skew appears. Without timeout fallback and asynchronous prefetch, any jitter in the cache layer passes uncertainty into the entire inference chain.
4. Remediation: Treat “Read Caching” as a Data Path That Needs Governance
The core of the remediation is not simply replacing the cache with a faster component. It is treating read caching as a complete data path and separately governing fixed cost, tail cost, and synchronization amplification.
1. Build layered observability
At minimum, break down the following metrics: L1 hit rate, L2 hit rate, number of cache-key lookups, average batch size for batch queries, remote query p50/p95/p99, serialization and copy time, cache-layer queueing time, timeout and fallback counts, and estimated computation savings from cache hits. Only by putting “how much each hit saves” and “how much each lookup costs” in the same table can you judge whether caching is truly worthwhile. When building similar systems in a general cloud environment, distributed caches, logging services, and monitoring/alerting can be brought into a unified observability plane, but the focus should remain on making read-cache costs observable rather than depending on a specific component.
2. Batch aggregation and asynchronous pipelines
Replace block-by-block lookups with batch queries, and make prefetching on non-critical paths asynchronous. A pseudocode sketch looks like this:
def read_blocks(request, block_ids):local = l1.batch_get(block_ids)missing = [bid for bid in block_ids if bid not in local]# Set explicit timeout and max batch for remote queries to keep tail latency off the critical pathremote = l2.batch_get(missing, timeout_ms=SMALL_TIMEOUT, max_batch=MAX_BATCH)# Fall back to computation on misses; merge hits before returningresult = merge(local, remote)return result, [bid for bid in missing if bid not in remote]
The key is not the code itself but three constraints: bounded batch size, bounded timeout, and fallback on miss. Cache lookups must not become an uninterruptible synchronous blocking point.
3. Locality-aware routing and cache admission
Route requests consistently based on request-context characteristics so that similar requests land on the same group of compute nodes as much as possible, improving L1 and L2 locality. At the same time, set an admission policy: cache only blocks with a high probability of reuse, avoiding pollution from low-frequency blocks and extra invalid lookups. Hot blocks can be replicated across shards, while cold blocks can be written lazily or skipped entirely.
4. Sharding, concurrency control, and backpressure
Shard L2 by cache key to avoid single-point hotspots; set upper limits for connection pools and concurrency queues; when cache-layer queueing exceeds a threshold, proactively downgrade to “skip the cache and compute directly” instead of continuing to queue. The goal of backpressure is to protect the main inference path, not the cache layer itself.
5. Coordinate with compute scheduling
In prefill context parallelism, cache lookups should be coordinated with compute scheduling: complete parallelizable local lookups and batch remote lookups first, then enter the stage that requires global synchronization. Cache requests that may time out should be marked in advance so they do not hold up accelerators in the same group. When necessary, move cache reads off the critical path into a prefetch stage and use computation to hide part of the lookup cost.
5. Validation: Do Not Look Only at Hit Rate
After remediation, three types of validation should be performed. First, measure net benefit by comparing end-to-end latency, throughput, and computation savings with the cache enabled and disabled. Second, measure the tail by focusing on p95, p99, and synchronization wait time. Third, measure stability by checking whether the system can keep the main path available through timeout fallback when the cache layer jitters, hotspot skew occurs, or the miss rate rises. During canary release, keep both the cache toggle and the ability to roll back by request percentage, rather than enabling it for all traffic at once.
The final conclusion can be summarized in one sentence: a cache is not a free accelerator; it is a trade that must be accounted for. The network, queueing, serialization, and synchronization costs of read caching must be included in architecture design and metrics. Only when hit benefits reliably cover these costs and tail latency is effectively controlled does a shared cache become a true acceleration layer instead of a middle layer that holds the system back.
