Inference-Aware Load Balancing for LLMs (part 8): prefill and decode apart, disaggregated serving

Why long prompts stall every decoding stream on a shared replica, measured; prefill/decode disaggregation with the llm-d router behind NGINX Gateway Fabric, the header filter it silently needs, the decider that skips cached prompts, and the cost of the hop.
Hand-drawn: decode p99 from 30.6 to 812.7 ms behind long prefills, and the prefill hop from 0 of 5 to 5 of 5 with one header filter

On this page

Four streams decoding on one real replica: 30.6 ms between tokens at p99. Three 1,700-token prompts arrive and the p99 becomes 812.7 ms, the longest gap 845.6 ms: every stream stops while each prompt is prefilled. This is part 8 of Inference-Aware Load Balancing for LLMs: prefill/decode disaggregation with the llm-d router behind NGINX Gateway Fabric, configured on camera, the header filter without which nothing is disaggregated and nothing looks wrong, the decider that skips cached prompts, and what the extra hop costs. The KV transfer is simulated, and the post says exactly where. It goes with a video on the LevelUP I.T. YouTube channel.

One real replica: decode gaps alone and during long prefills
One real replica: decode gaps alone and during long prefills

Two phases, two costs

Prefill runs the whole prompt in one pass and fills the KV cache; it is bound by compute. On this lab's LFM2.5-1.2B (vLLM 0.32.0, CPU) it took about 46 ms + 0.524 ms per prompt token (0.072 s at 71 tokens, 0.280 s at 446, 0.481 s at 858, 0.945 s at 1,716, unique prompts). Decode makes one token per step for every running sequence and reads the weights and the KV cache each step; it is bound by memory bandwidth: 13.5 ms per token at one stream, 16.3 ms at eight. A server batches both, so a long prefill makes a step long and every decoding sequence waits for it. Time to first token is a prefill number; time per output token is a decode number.

Interference, measured

A new tool, pd.py (in the lab's llm-tools), on one real replica: four streams decode 256 tokens each, alone, then again while three unique ~1,700-token prompts arrive one after another.

pd interfere http://$P:8000 lfm2.5-1.2b
4 decode streams, alone        : gap between tokens median  13.4 ms, p99   30.6 ms, longest   73.8 ms  (1024 gaps)
4 decode streams, with-prefills: gap between tokens median  11.8 ms, p99  812.7 ms, longest  845.6 ms  (1024 gaps)
   long prompt: 1719 tokens, its prefill (time to first token) 0.887 s
   long prompt: 1715 tokens, its prefill (time to first token) 0.890 s
   long prompt: 1730 tokens, its prefill (time to first token) 0.918 s

The median barely moved; the tail is the prefill, once per long prompt per stream. Chunked prefill shortens each stall; it does not remove it, because decode steps still share the machine with the prefill. Disaggregation runs prefill on its own server and moves the KV cache to a decode server, so decoding streams never share a step with a new prompt. The price is a second hop and the transfer: vLLM reports 328,884 tokens in 4 GiB for this model, 13.1 KB per token, so an 870-token prompt carries about 11.4 MB.

This post is for paying subscribers only

Subscribe to LevelUp I.T. newsletter and stay updated.

Don't miss anything. Get all the latest posts delivered straight to your inbox. It's free!
Great! Check your inbox and click the link to confirm your subscription.
Error! Please enter a valid email address!