Real Time Updates hard
Your WebSocket server pushes data faster than the client reads it. Eventually, the `send()` buffer fills up. How does the underlying TCP protocol handle this initially?
- A It drops packets.
- B It sends a reset packet.
- C It closes the socket.
- D The client advertises a 'Zero Window', telling the server's OS to stop sending data. The server's OS blocks the application's write calls.
Answer: D. The client advertises a 'Zero Window', telling the server's OS to stop sending data. The server's OS blocks the application's write calls.
This is TCP Flow Control. The receiver tells the sender how much buffer space it has (Window Size). When it hits 0, the sender stops transmitting on the wire, causing the sender's memory usage to spike if the app keeps writing.
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?