Interview Prep/Networking/Load balancers and reverse proxies

Server-Sent Events / streaming responses work directly against the app, but through nginx they arrive all at once at the end.

IntermediateTroubleshootingLoad balancers and reverse proxies
Answer

Likely causes → nginx buffers upstream responses by default and only flushes when buffers fill or the response ends. Compression (gzip on) and some LBs add more buffering.

Diagnose →

curl -N http://127.0.0.1:8080/stream       # direct: events trickle in
curl -N https://app.example.com/stream     # via nginx: all at the end

Fix →

location /stream {
    proxy_pass http://app;
    proxy_http_version 1.1;
    proxy_set_header Connection "";
    proxy_buffering off;
    proxy_read_timeout 1h;
    gzip off;
}

Or have the app send X-Accel-Buffering: no for streaming responses.

Prevent → Mark streaming endpoints explicitly in proxy config and include them in end-to-end tests through the real proxy chain.

All Networking questions Roadmap: Networking for DevOps

More on Load balancers and reverse proxies