Cross-cutting concerns (the O in RADIO) · senior
Real-time: polling, SSE and WebSockets
Pick the simplest transport that meets the need: polling for slow changes, Server-Sent Events for server-to-client streams, WebSockets for two-way low-latency traffic. Then design reconnect with backoff, ordering by sequence numbers, removing duplicates, and catch-up after a gap.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Short polling: simple and cache-friendly but wasteful; at Uber, about 80% of API gateway requests were polls before they built a push platform.
- Long polling: the server holds the request until there is data; works everywhere; one request per message.
- SSE (EventSource): one-way server → client over HTTP; automatic reconnect; the id: field lets the server resume; text only; on HTTP/1.1 browsers allow only about 6 connections per domain across tabs (HTTP/2 negotiates around 100 streams).
- WebSocket: two-way, binary, low latency; you build heartbeats, reconnect, auth refresh and backpressure yourself; needs stateful connection servers.
- Reconnect with exponential backoff plus jitter (avoid a thundering herd); on reconnect send the last sequence number; the server replays missed events; delivery is at-least-once, so dedupe by id.
- Heartbeats: Uber's RAMEN sends a 1-byte heartbeat every 4 s and the client reconnects after 7 s of silence.
- Ordering: per-channel server sequence numbers, never client clocks; buffer out-of-order events; on a gap, resync with a snapshot.
- UI: batch high-frequency updates per frame; slow down when the tab is hidden; keep presence/typing on an ephemeral channel; share one connection across tabs (leader tab via Web Locks/SharedWorker, BroadcastChannel to fan out).
The red pen
Common traps: mistake → fix
Mistake: WebSockets are always the best choice
Fix: SSE is simpler for one-way streams; polling is fine for slow data.
Mistake: Order messages by client timestamps
Fix: clocks differ; use server sequence numbers.
Mistake: Reconnect immediately in a loop
Fix: thousands of clients hammer the server; use backoff with jitter.
Mistake: The server delivers exactly once
Fix: design for at-least-once and make handling idempotent.
Easy to hard
Questions interviewers ask, easy to hard
- Polling vs long polling vs SSE vs WebSocket: when each?
- The connection drops for 30 seconds. What happens when it comes back?
- Messages arrive out of order or twice. How do you handle it?
- 1,000 updates per second reach the browser. How do you render them?
Practise
Practise with these questions
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.