Three ways to deliver server-pushed updates; pick based on direction, scale, and infra constraints.
Pick a scenario below and see which option fits, and why.
There is no universal winner here, only the right fit for a given situation. Each scenario above pushes the decision a different way, which is exactly how this tradeoff shows up in real design questions.
Plain English: how do you let the SERVER push something to the browser (instead of the browser asking repeatedly)? Three answers: poll often (simple, wasteful), keep a one-way pipe open (SSE), or open a two-way pipe (WebSocket). Each has its place.
Three techniques for server-to-client updates over HTTP: long-polling (client opens a request, server holds it until data is ready, then closes), WebSockets (bidirectional persistent TCP connection upgraded from HTTP), Server-Sent Events (one-way HTTP stream from server to client over a single long connection).
HTTP is request-response, so the client has to ask. For 'tell me when something happens' use cases (chat messages, notifications, live updates), you need a way for the server to push.
Long-polling: client makes a request, server holds it (up to ~30s) until data appears or it times out, then client reconnects. WebSockets: HTTP upgrade handshake, then a persistent TCP connection both sides can write to. SSE: server holds a single HTTP response open and writes events to it, giving a one-way, simple stream with auto-reconnect built-in.
WebSockets: bidirectional, low-latency message delivery
WebSockets via the gateway tier; pub/sub for cross-box fanout
Long-polling for sync notifications, which works through every corporate firewall
Real-time communication questions test whether you can pick the right protocol for the direction of data flow. For bidirectional chat you want WebSockets, for server-push notifications you should say SSE (simpler, no proxy issues), and for maximum compatibility you fall back to long-polling. The gotcha to proactively mention is that WebSockets need sticky load balancing: a round-robin load balancer drops connections constantly. Candidates lose points by defaulting to WebSockets for everything without discussing connection management at scale.