0️⃣ Quick Comparison
| Feature | Polling | Long Polling | SSE | WebSocket |
|---|---|---|---|---|
| Real-time | ❌ | ⚠️ Almost | ✅ | ✅ |
| Persistent Connection | ❌ | ⚠️ Temporary | ✅ | ✅ |
| Direction | Client → Server | Client → Server | Server → Client | Bi-directional |
| HTTP Based | ✅ | ✅ | ✅ | Starts with HTTP |
| Server Push | ❌ | ⚠️ Sort of | ✅ | ✅ |
| Complexity | Low | Medium | Medium | High |
| Scalability | Poor | Better | Good | Good |
Think of a cricket score app 🏏.
“How does the server push real-time updates to clients?“
1️⃣ Polling
The client repeatedly asks: > “Any new updates?” at a fixed interval.
Example
Client calls: GET /score every 5 seconds.
Client Server
Request --------------->
Current Score = 100
<--------------- Response
(wait 5 sec)
Request --------------->
Current Score = 100
<--------------- Response
(wait 5 sec)
Request --------------->
Current Score = 120
<--------------- ResponsePros
- Simple
- Easy to implement
- Works everywhere
Cons
- Lots of unnecessary requests
- High server load
- Updates are delayed. you get stale data of
5 sec- If polling interval = 5 sec
Server updated at 10:01-Client sees at 10:05
- If polling interval = 5 sec
System design Use Cases
- Monitoring pages - Dashboard refresh every
1 min
Note: Not suitable for chat apps
2️⃣ Long Polling
Instead of immediately responding: Server waits until new data arrives.

Pros
- Almost real-time
- Atleast better then Polling
Cons
HTTPConnection repeatedly opens/closes- Scalability - Doesn’t scale as well for millions of users - creates http overhead
System design Use Cases
- Notification systems
- Before WebSockets became common
3️⃣ SSE (Server-Sent Events)
SSE keeps one HTTP connection open. Server continuously pushes updates.

Server seding cricket score data.
data: Score = 100
data: Score = 120
data: Score = 150Characteristics
| Feature | SSE |
|---|---|
| Direction | Server → Client |
| Protocol | HTTP |
| Persistent Connection | Yes |
| Auto Reconnect | Yes |
| Browser Support | Excellent |
Pros
- Simpler than WebSockets
- Uses HTTP
- Automatic reconnection
- Lower overhead compair to long polling as connection remain open
Cons
- One-way communication - Client cannot push data through same connection
Interview Use Cases
- Stock prices
- Great for live feeds
- Live sports score
- News feed
- Monitoring dashboard
4️⃣ WebSockets
WebSocket creates a persistent TCP connection. After connection establishment:
Client <---------> ServerBoth sides can send messages anytime.
Handshake
When the browser wants a WebSocket:
const socket =
new WebSocket("wss://chat.example.com");Starts as HTTPS:
GET /chat HTTP/1.1
Host: chat.openai.com
Upgrade: websocket
Connection: UpgradeServer:
HTTP/1.1 101 Switching Protocols
Upgrade: websocket
Connection: UpgradeThe connection becomes: WebSocket Protocol over the same TCP connection.
Flow

Characteristics
| Feature | WebSocket |
|---|---|
| Direction | Two-way |
| Persistent | Yes |
| Real-time | Yes |
| Protocol Upgrade | Yes |
Pros
- Lowest latency
- Bi-Directional
- Efficient - less overhead compair to http based soluation
- Ideal for real-time apps
Cons
- More complex
- Stateful connections - Load balancing becomes harder
- scalability Issue
System Design Use Cases
- Chat applications
- Slack
- Multiplayer games
- Trading platforms
- Collaborative editors
- ChatGPT
System Design Rule
If interviewer asks:
User refreshes every minute
➡️ Polling
Notification service
➡️ Long Polling or SSE
Live cricket score
➡️ SSE Reason:
- Server pushes updates
- Client rarely sends data
- Simpler than WebSocket
WhatsApp / Slack
➡️ WebSocket Reason:
- User sends and receives messages continuously
- Bidirectional communication required
WebSockets are not easier to scale than stateless HTTP. They require maintaining long-lived stateful connections, sticky routing, connection management, and often a shared messaging layer like Redis Pub/Sub or Kafka. However, for large-scale realtime systems they are much more network-efficient than polling because they avoid repeated requests and allow instant bidirectional communication.