Explain WebSocket vs SSE vs Long Polling.

WebSockets, Server-Sent Events (SSE), and long polling are three different techniques for enabling real-time communication between a client and server.

When to Use

  • WebSockets: Best for two-way interactive apps like chat, multiplayer games, or collaborative editors.
  • SSE: Great for one-way server updates such as stock tickers, notifications, or dashboards.
  • Long polling: Simple fallback when WebSockets/SSE aren’t supported, but less efficient.

Example

Think of a live cricket score app: WebSockets update scores instantly both ways, SSE streams updates one-way, and long polling keeps asking the server for new scores repeatedly.

Want to go deeper?

Explore Grokking System Design Fundamentals, Grokking the System Design Interview, or prepare with Mock Interviews with ex-FAANG engineers.

Why Is It Important

Choosing the right approach directly impacts latency, scalability, and user experience in real-time systems.

Interview Tips

In interviews, clearly define each:

  • WebSockets = two-way persistent connection.
  • SSE = one-way server push.
  • Long polling = repeated HTTP requests. Then, tie them to practical examples (chat app, notification feed, etc.).

Trade-offs

  • WebSockets: low-latency but needs persistent connections.
  • SSE: simple, lightweight, but one-way only.
  • Long polling: works anywhere but high server overhead.

Pitfalls

  • Using SSE where client-to-server updates are required.
  • Relying on long polling for high-frequency events (server overload).
  • Forgetting reconnection handling in WebSockets or SSE.
TAGS
System Design Interview
System Design Fundamentals
CONTRIBUTOR
Design Gurus Team
-

GET YOUR FREE

Coding Questions Catalog

Design Gurus Newsletter - Latest from our Blog
Boost your coding skills with our essential coding questions catalog.
Take a step towards a better tech career now!
Image
One-Stop Portal For Tech Interviews.
Copyright © 2025 Design Gurus, LLC. All rights reserved.