Skip to content
We areTOP 1%

How do short polling, long polling, WebSockets and Server-Sent Events differ?

MediumConceptAPIs & Communication
Track your progress
First attempt
Re-solve after a few days
Final pass before interviews

Answer

All four deliver server-side updates to clients, but they trade simplicity against latency and overhead.

  • Short polling: the client asks for updates at a fixed interval. It is simple, but it wastes requests when nothing has changed and adds up to one interval of delay.
  • Long polling: the server holds the request open until data is available or a timeout occurs, and the client then reconnects immediately. Latency is lower, but every message still costs a new HTTP request.
  • WebSockets: a single persistent, full-duplex TCP connection established through an HTTP upgrade; best for chat, games and collaborative editing, although long-lived connections complicate load balancing.
  • Server-Sent Events: a one-way stream from server to client over plain HTTP with automatic reconnection; well suited to feeds, notifications and live scores.

More in APIs & Communication

Sign in to track your progress

Your checkboxes, streak and activity heatmap are saved to your account and sync across devices. It is free.
Sign in with email

New here? Create an account