Repaso
Español
System DesignIntermediateSD-20

A chat app needs the server to push messages instantly to clients. Most suitable transport?

Options

  1. Polling the server every 30 seconds
  2. WebSockets (or Server-Sent Events for one-way push) (Correct option)
  3. SMTP, the protocol for email delivery
  4. Plain HTTP/1.0 with a new connection each time

Answer

WebSockets (or Server-Sent Events for one-way push)

Why

Normal HTTP only lets the client ask; the server cannot speak first. Polling ('any news?') every few seconds is wasteful and slow.

A WebSocket keeps one connection open, and both sides can send messages at any time, with very low delay.

Server-Sent Events are a simpler option when only the server needs to push (e.g. live scores).

Remember

Real-time two-way → WebSockets.

Key terms

Practice this question in Repaso