HAProxy's 200ms LLM token delay explained: a kernel flag, not a buffer bug
A benchmark comparing four reverse proxies showed HAProxy delivering LLM tokens 206 milliseconds late and in bursts, while nginx, Caddy, and Traefik passed them through in 2–3 milliseconds. An HAProxy engineer investigated and found the delay is not caused by application-level buffering but by the kernel's MSG_MORE flag, which HAProxy intentionally sets to hold small writes until more data arrives. This behavior stems from a documented default designed to batch small packets into full-sized ones, improving efficiency for the high-concurrency bulk HTTP traffic HAProxy typically handles. The delay disproportionately affects LLM token streams because their frames — around 60 bytes every 50 milliseconds — are too small to fill a packet, triggering the hold repeatedly. The behavior can be disabled with a single line of configuration, and larger frames reduce the delay significantly.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)
Log in to join the discussion and vote.
Log in