Real Time Updates medium
WebSockets run over TCP. Does this make them immune to Head-of-Line (HOL) Blocking?
- A Yes, because WebSockets are bidirectional.
- B Yes, because they run over HTTP/1.1.
- C No. Since TCP guarantees order, if Packet 1 is lost, Packet 2 and 3 must wait in the OS buffer until Packet 1 is retransmitted, causing latency spikes.
- D No, but only on mobile networks.
Answer: C. No. Since TCP guarantees order, if Packet 1 is lost, Packet 2 and 3 must wait in the OS buffer until Packet 1 is retransmitted, causing latency spikes.
TCP enforces ordered delivery. Even though the application logic might not care if 'Player Pos X' arrives before 'Player Pos Y', the TCP stack enforces it. This is why WebTransport (over QUIC/UDP) is the future for latency-sensitive streams.
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?