nginx Buffering Delayed Claude Streaming Responses, Raising First-Token Time to Seconds
A developer found that their Claude chat app streamed smoothly locally but stalled for several seconds once deployed behind nginx. The cause was nginx's default proxy_buffering, which collects upstream data and sends it in chunks, turning token-by-token server-sent events into delayed bursts. Replaying 200 prompts showed median time to first token rising from 0.71 seconds to 3.4 seconds, with some replies arriving as a single block. Disabling proxy_buffering on the streaming route, or sending an X-Accel-Buffering: no header from the app, resolved the issue, though a regex location rule initially overrode the fix. After the change, median first-token time dropped to 0.76 seconds.
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