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
Boost your coding skills with our essential coding questions catalog.
Take a step towards a better tech career now!
Explore Answers
Related Courses
Grokking the Coding Interview: Patterns for Coding Questions
Grokking the Coding Interview Patterns in Java, Python, JS, C++, C#, and Go. The most comprehensive course with 476 Lessons.
4.6
$197

Grokking Modern AI Fundamentals
Master the fundamentals of AI today to lead the tech revolution of tomorrow.
3.9
$78
Grokking Data Structures & Algorithms for Coding Interviews
Unlock Coding Interview Success: Dive Deep into Data Structures and Algorithms.
4
$78
One-Stop Portal For Tech Interviews.
Copyright © 2025 Design Gurus, LLC. All rights reserved.