Zero Labs
Industry News / AI

The KV Cache Is Just Session State: Disaggregated Inference for Backend Engineers

Source · Towards AI By Soumil Gada

From the publisher’s feed, collected in the ZeroLabs newsroom.

Prefill, decode, and why routing an LLM request is closer to routing a shopping cart than a stateless API callDisclosure: I drafted parts of this article with AI writing tools. I edited all of it, checked the claims against the sources linked below, and ran the code myself.If you run backend systems, you already know most of what you need to reason about LLM serving. Sticky sessions, session stores, hot keys and moving state between nodes all carry over; only the vocabulary is new.This came up after I read a vLLM post from 12 October 2026 about routing by conversation ID. Its numbers are easy to over-read, so I go through them below, after the mental model.Two phases with different bottlenecksServing one LLM request has two phases. Prefill is where the model reads your whole prompt. All the input tokens can be processed in parallel, so this phase is compute-bound, and how long it takes sets the time to first token (TTFT), the pause before the user sees anything.Decode is where the model writes the answer one token at a time. Each new token needs the results already computed for every earlier token, so the work is dominated by reading memory rather than by arithmetic. It is memory-bandwidth-bound, and it sets the gap between tokens (ITL).The vLLM disaggregated serving guide (29 September 2026) says the same. When both phases share one GPU they interfere, and a long prefill stalls everyone’s decode. It’s the noisy-neighbour problem inside one box.The KV cache is session stateThose “results already computed for every earlier token” are the KV cache. The useful reading for a backend engineer is that it’s per-conversation state that makes the next request cheap. Three properties matter.It costs memory, and a lot of it. The same vLLM guide gives Llama-3.1–70B in BF16 at 320 KiB of KV cache per token, so a 10,000-token prompt is about 3 GB. A hundred such conversations held at once is on the order of 300 GB (my arithmetic).A miss is expensive. If the cache isn’t on the node that receives turn five, that node redoes the prefill for the entire history, so the user pays in TTFT and you pay in GPU time.Routing therefore matters. Send turn five to the node holding the state and it only processes the new message; send it elsewhere and it reprocesses everything. That’s the reason you used sticky sessions in the first place, and chat makes it worse because, as the Splitwise paper (arXiv 2311.18677) notes, a chat client resends the whole conversation each turn.What disaggregation buys, and what it costsDisaggregated inference splits the phases onto separate pools. Prefill nodes read prompts, decode nodes hold the state and stream tokens, and the KV cache travels between them. From the papers and the vLLM guide, the gains are these:DistServe (arXiv 2401.09670) removes prefill-decode interference and lets each phase pick its own parallelism. It reports up to 7.4x more requests served, or a 12.6x tighter latency target met. These are maxima against different baselines and tasks, not one figure.Splitwise reports up to 1.4x throughput at 20% lower cost, or 2.35x throughput at the same cost and power.The vLLM guide frames the gain as goodput, meaning requests that meet their latency target, rather than peak throughput. AMD’s own benchmark, as reported in the guide, had 73 of 100 requests meeting a 1 s TTFT and 50 ms ITL target against 30 of 100 colocated.These come from specific setups, and none belongs in a business case for your workload. The costs matter just as much.You run three or four services instead of one, and KV transfer becomes a new failure mode. The transfer can also eat the gain. On two L40S GPUs with 8k-token prompts, the guide measured colocated p99 ITL jumping from 23 ms to 169 ms at 0.4 requests per second, while disaggregated stayed between 25 and 52 ms. Median TTFT was worse, though, at 2.2 s against 0.7 s at 0.2 requests per second, because a slow transfer of about 1.3 s (no peer-to-peer or RDMA on that box) landed on every first token. DistServe lists fault propagation and a weak fit for resource-constrained setups as limits. The guide’s advice is that colocated stays right for low, bursty or TTFT-bound traffic.What the vLLM post measuredThe post is about “bi-directional KV transfer” for multi-turn and agentic workloads (https://vllm.ai/blog/2026-10-12-bidirectional-kvxfer-multiturn-agentic-workload). In a plain disaggregated setup, KV moves one way, from prefill to decode. Here the decode node keeps the conversation’s KV for a while, and on the next turn a router sends the request to the prefill node with a pointer to that state. The prefill node pulls the existing KV back and computes only the new tokens.The router is a small stateful service that maps a conversation_id to the decode node's transfer metadata, while the tensors move node to node. Two defaults are worth knowing. The decode node holds state for 480 seconds (fixed, not renewed per turn), and below a 64-token threshold the system recomputes. The post doesn't say it in one sentence, but I infer that without a conversation_id every turn is a cache miss and gets recomputed.The headline is average TTFT up to 1.6x lower for Qwen3–32B and up to 3.3x lower for GLM-5-FP8. The details matter here.The ratios are ratios of average TTFT, not p50 or p99, with the feature on against off at the longest prompts tested. For Qwen3–32B at 24k tokens, TTFT was 778 ms off and 460 ms on. That’s up to 1.6x, as the post states (my division gives 1.69x). For GLM-5-FP8 at 20k tokens it was 2,334 ms off and 702 ms on, which is the 3.3x. At 2k tokens the gaps are much smaller (158 ms against 122 ms for Qwen3–32B).With the feature off, prefix caching was disabled on the prefill node, to emulate a cold or different prefill node. The baseline is therefore “recompute everything”, and it isn’t a comparison against round-robin or consistent hashing.The setup was one prefill node and one decode node, each a p5en.48xlarge (8x H200) with EFA networking, in the same availability zone in AWS Mumbai (ap-south-1b), using an on-demand capacity reservation, plus a third small node for the proxy and client.The post says results depend on workload and configuration. The transfer isn’t free: roughly 30 to 130 ms for Qwen3–32B and 29 to 110 ms for GLM-5-FP8.The router is an example proxy, and the vLLM guide says to use a production stack for real traffic.My reading: on a fast interconnect, reusing session state beats recomputing it, and the benefit grows with prompt length and model size. It doesn’t say a router makes everything 3x faster, and the figures compare reuse against full recompute on H200 nodes with EFA, so they aren’t a promise for your stack.Why consistent hashing falls shortThe obvious backend answer is to hash the conversation ID onto a ring. You get affinity without a lookup table, and it survives adding nodes better than modulo does, but it falls short here. One reason is visible in Ray Serve’s LLM docs, and the others are my own reasoning.Ray ships a ConsistentHashRouter that hashes an x-session-id header, and its docs state the cost plainly: a session with more turns or longer sequences can saturate its replica. From here on it's my reasoning, not the docs. The hash key is the conversation, but the cost of a conversation isn't uniform. A request's price grows with its context length, so one long-running agent can be worth a hundred short chats, and the ring can't see that.The same docs describe an alpha KVAwareRouter that routes on token load, meaning the prefill work remaining after cache overlap plus the work in flight on each replica. It learns where state lives from vLLM's KV events. The caveats are that it has no prefill-decode disaggregation support yet, and its overhead may not pay off on uniform workloads.In my view a good router needs three things a hash can’t give: which node holds the state, how loaded it is, and what a miss would cost. The conversation_id table in the vLLM post is the simplest version of the first.A toy simulationTo see the tension between affinity and balance I wrote a toy model (router_sim.py). It isn't a benchmark of vLLM, Ray or anything else, and it has no queueing, no decode and no network. It generates multi-turn conversations with a heavy-tailed number of turns, gives each of 8 replicas an LRU cache of conversation prefixes, and counts prefill tokens computed. Results are averages over 20 seeds.With the default setup (2,000 conversations, 300,000-token cache per replica):Round-robin served 44.8% of prompt tokens from cache.Consistent hash on the conversation ID served 86.9%. A pinned conversation-ID table that places new conversations on the least-loaded replica also served 86.9%, and a cache-aware scorer that adds current load served 84.6%.Total prefill work, relative to round-robin, was about 23.5% for both affinity routers and 27.6% for the scorer.Balance looks fine at that scale, with the busiest replica’s prefill work (tokens computed, not request count) at 1.16 times the mean for hashing. It changes when conditions tighten. With only 200 conversations the busiest replica under hashing was 1.37 times the mean (1.30 for the pinned table). With 2,000 conversations but a small cache per replica, hashing reached 2.10 times the mean, the pinned table 1.56, and the load-aware scorer 1.03, at the price of a lower hit rate (56.9% against 65.1% for hashing and 69.5% for the table).Directional only: affinity gives most of the win, hashing leaves some replicas hotter, and balancing harder costs cache hits.The fintech angleIn-house models for KYC review, disputes or support are multi-turn, with long documents and policy text up front, which is where reusing state matters most. If your prompts are short and one-shot, little of this applies.A KV cache holds a derivative of the customer’s conversation in GPU memory for as long as your TTL says, so your retention and residency policies should name it. Take it to security and compliance, and ask any vendor the same.Build or buy: the cost sectionAWS EC2 on-demand, Linux, shared tenancy, Asia Pacific (Mumbai), p5en.48xlarge costs $75.9552 per hour per instance, from the AWS price list file for ap-south-1 (publication date 12 October 2026, https://pricing.us-east-1.amazonaws.com/offers/v1.0/aws/AmazonEC2/current/ap-south-1/index.json). A setup like the one in the vLLM post needs two (plus a small node for the proxy), so $151.9104 per hour for the GPU pair before storage, networking, redundancy and people.The Anthropic API price for Sonnet 5.5 is $2 per million input tokens and $10 per million output tokens, standard tier, from https://www.anthropic.com/pricing, checked 15 October 2026.Arithmetic on those two: $151.91 an hour buys about 76 million input tokens or about 15 million output tokens from that API. That’s a reference point, not a verdict. The models and their quality differ, and a self-hosted pair has to stay busy and redundant to compete. An idle GPU costs what a busy one does.My rule of thumb for the decision:Buy a managed API when traffic is spiky, volume is low, or you cannot staff an inference team.Build when volume is steady and high, or policy requires the model inside your boundary. Start colocated and measure.Disaggregate only when you can show decode stalls from long prefills and you have fast interconnect. The guide’s advice to measure TTFT on turn five, not turn one, is the right test.Questions for your teamWhat is our TTFT and ITL at turn one and at turn five, at p50 and p99?Where does conversation state live, for how long, and who can read it?What happens when a KV transfer fails? vLLM offers fail or recompute for that case, so which one are we choosing, and why?How does the router learn a node lost its state, and what does a miss cost?Which conversations are the hot ones, and does anything cap them?Are we on a production stack or an example proxy?Follow me for more on system design and the trade-offs behind it.The KV Cache Is Just Session State: Disaggregated Inference for Backend Engineers was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.