Real-time Updates
Difficulty: Medium | Topic #16
What to Learn
WebSockets for full-duplex persistent connections, SSE for server-to-client streams, long polling as a fallback; when to pick each; connection management at scale (sticky sessions or pub-sub relay).
Resources
- Hello Interview: Real-time Updates Pattern ↗
- Hussein Nasser: WebSockets vs SSE vs Long-Polling ↗
- Ex-Google SWE: Long Polling vs WebSockets vs SSE ↗
Covered by Problems
| Problem | Difficulty | Link |
|---|---|---|
| Messaging App (WhatsApp) | Medium | → |
| Live Comments (FB Live) | Medium | → |
| Online Auction | Medium | → |
| Online Chess | Hard | → |
| Real-time Doc Collaboration (Google Docs) | Hard | → |
| Ride Sharing (Uber) | Hard | → |
| Stock Trading Platform (Robinhood) | Hard | → |
Key Concepts to Master
- WebSocket handshake and upgrade process
- SSE vs WebSockets — unidirectional vs bidirectional
- Long polling overhead vs WebSocket connection cost at scale
- Pub-sub relay (Redis Pub/Sub, Kafka) to fan out to WebSocket servers
- Connection draining on server restarts