Summary

Polling repeatedly asks for updates. SSE streams server-to-client events over HTTP. WebSockets provide full-duplex communication over a long-lived connection.

Interview Points

  • Polling is simple but wasteful and less fresh.
  • SSE is good for one-way server-to-client updates.
  • WebSockets are good for bidirectional, low-latency interaction.
  • SSE works naturally with HTTP and has automatic reconnection.
  • WebSockets need connection management, scaling, and backpressure handling.

2-3 Minute Interview Script

“Polling is the simplest model: the client asks for updates every few seconds. It is easy to implement but can waste resources and has freshness delays.

Server-Sent Events are better when the server needs to push a stream of updates to the browser, like notifications or live status. SSE is one-way from server to client and works over regular HTTP.

WebSockets are full-duplex, so both client and server can send messages anytime. They are a better fit for chat, collaboration, games, or interactive dashboards.

In an interview, I would choose polling for simple low-frequency updates, SSE for one-way live updates, and WebSockets for bidirectional low-latency communication.”

Follow-Ups

  • How do you scale WebSockets?
  • Why might SSE be simpler than WebSockets?