Real Time Updates hard
You deploy a WebSocket server behind Nginx. Connections work, but messages are delayed and arrive in chunks. What Nginx setting is likely the culprit?
- A Proxy Buffering is enabled. Nginx waits to fill a buffer (e.g., 4KB) before sending it to the client. WebSockets require `proxy_buffering off;` to stream real-time frames.
- B Gzip compression.
- C SSL Handshake time.
- D Worker connections limit.
Answer: A. Proxy Buffering is enabled. Nginx waits to fill a buffer (e.g., 4KB) before sending it to the client. WebSockets require `proxy_buffering off;` to stream real-time frames.
Buffering is great for HTML (saves backend connection time) but terrible for streaming. It destroys the real-time aspect by holding small 'chat messages' hostage until enough accumulate to fill a block.
One system design question a day, with spaced repetition so the ones you miss come back.
Get the appRelated questions
- When a mobile app is closed/backgrounded, it cannot keep a WebSocket open. How does it receive real-time alerts (like 'New Message')?
- For a human user, what is generally considered the maximum acceptable latency for an interaction to feel 'Real-Time' (e.g., typing in a Google Doc)?
- If you want to update a news feed on a website every time a new article is published, what is the simplest (but least efficient) 'Real-Time' technique?
- In a persistent real-time connection, what is the purpose of a 'Heartbeat' or 'Ping/Pong' message?
- Why is Short Polling considered 'Chatty'?
- Server-Sent Events (SSE) are ideal for which type of real-time application?