← All engineering notes

Serving · 2026-11-13

A cache hit is not the end of the journey

Our cache hit rate was 98.6%, yet the first token still took 3.6 seconds. Following the bytes showed where the time went, and why a hit-rate dashboard can mislead.

98.6%cache hit rate, 3.6 s first token
57%of first-token time was KV transfer
35 → 2.5s first-token p50 with admission control

Split the first token into stages

We stitched together per-request logs from four layers (gateway, entry, prefill and decode) for 5,858 requests between October 19 and 21, then attributed the average first-token time to each stage.

9%Gateway dispatch32%Prefill of the uncached part57%KV transfer, prefill → decodeOtherShare of mean first-token time, 5,858 requests, Oct 19–21.
Fig. 1 · More than half of the first token was spent moving KV that decode already could have had.

The transfer volume did not depend on the hit rate at all. It was a straight line in input length.

KV bytes sent from prefill to decode vs. input lengthinput length →MBtransfer = 0.4175 MB × input length · R² = 1.0000Same at 98.6% cache hit: the full KV is still sent.Points are illustrative of the fit; the relationship is from 5,858 logged requests.
Fig. 2 · Bytes sent per request scale with the whole input, hit or miss.

Two causes. First, prefix reuse was not enabled on the decode side, so prefill always sent KV from token zero. Second, the gateway applied session affinity only to prefill (99.4% of turns returned to the same prefill node) while only 6.7% of decode turns returned to the same decode node. A third finding was about reading metrics: a "connect 1.6 s" field was really time spent waiting for prefill to finish; the handshake itself took tens of milliseconds.

Route to where the KV already is

Cache-affinity routingSession A · turn 1Session A · turn 2Gatewayhash by sessionMachine 1 · holds A's KVturn 2 computes only the new partMachine 2would recompute from scratch
Fig. 3 · The second turn contains the whole first turn. Sending it back to the same machine reuses the KV and computes only what is new.

For GLM, consistent hashing sends a session back to the same prefill node, which raised the prefix hit from 0.64 to 0.98. For GLM-5.3-Flash, routing by prefix to the same replica gives near-100% affinity. Hit rates today: GLM 97–99%, DeepSeek about 96%.

Say no when the system is full

First token p50—35 s · no admission control2.5 s · with admission controlFirst token p99—68 s4.2 sTwo independent drills on a standby instance, Oct 18 and 19.
Without admission controlWith admission control
Fig. 4 · Admission control trades a few fast rejections for a usable first token for everyone else.

Read a hit, don't recompute it

0.010.1110Local memory (same NUMA side)0.07–0.14 sAnother machine's memory (RDMA)0.02–0.15 sLocal NVMe≈1.0 sShared storage≈1.9 sRecompute (prefill again)≈7–14 sProjected from bandwidth measured Oct 21; the recompute row is an order-of-magnitude estimate.
Fig. 5 · KV storage tiers, reordered by measured bandwidth.
  • Another machine's memory over RDMA is about 7× faster than local NVMe and as fast as local memory. Across the cluster, about 39 TB of memory can act as one shared KV pool.
  • Writes to host memory must stay on the local NUMA side: split writes from 8 GPUs reach 144 GB/s; writing everything to one side drops to 46 GB/s.
  • One GPU sending to many machines does not add bandwidth. To go faster, use more GPUs and more NICs at once.

Next

DirectionMeasured basisExpected (projected)
Send only missing KV57% of first token is KV transfer; full KV sent at 98.6% hitFirst-token median 3.6 → about 1.2–1.4 s
Decode KV residency and releaseAt 90% KV occupancy only about half is generating+23% to +42% throughput ceiling on the same machines
Entry overheadAlready-cached context still costs about 8 ms per 1K tokensLower long-context first token

Projections are estimates, not results. Every change goes through an idle-machine canary, benchmark and approval first.

Data & sources

TestObserved resultScope
First-token breakdown57% KV transfer5,858 requests, Oct 19–21
Transfer volume0.4175 MB × inputR² = 1.0000
Admission controlp50 35 → 2.5 s · p99 68 → 4.2 sStandby drills, Oct 18–19

October 2026 engineering measurements on the stated hardware and workload. They are not a cross-model ranking or a service-level guarantee.

This work runs underneath Zenith Tokens.

Try Zenith Tokens