Tags

WebSockets

WebSockets

0 lessons
5 system designs

websockets

System Design

5 articles
System Design

WebSockets, Long Polling & SSE

Standard HTTP is a request-response protocol: the client asks, the server answers. But many modern applications need real-time, bidirectional communication - chat messages, live notifications, stock tickers, collaborative editing, and gaming. This lesson covers three techniques for real-time communication: long polling, Server-Sent Events (SSE), and WebSockets. You will learn how each works, their trade-offs, and when to use which in a system design interview.

websockets
long-polling
sse
server-sent-events
real-time
bidirectional
push
intermediate

379

9

Medium
System Design

Design a Chat System (WhatsApp)

Design a real-time chat system like WhatsApp serving 2B users sending 100B messages per day with sub-second delivery, presence indicators, and read receipts. The interview centerpiece is the persistent WebSocket connection layer: how many connections per server, how to route a message to a recipient who may be on a different server, and how to guarantee delivery when the recipient is offline. We cover the message delivery state machine (sent, delivered, read), the connection routing layer that maps user_id to a chat server, the message store for offline delivery, and presence/typing indicators that operate at a higher write rate than messages themselves.

design-chat-system
case-study
messaging-communication
chat
websockets
real-time
presence
delivery-receipts
at-least-once
fan-out
session-affinity
system-design
intermediate
free

664

16

Medium
System Design

Design a Ticketing System (Ticketmaster)

Design a Ticketmaster-style ticketing platform that sells reserved seats for concerts and sports events, with the central challenge being a flash onsale where 1M users compete for 50K seats in five minutes. The interview centerpiece is the seat reservation lock: each unique seat (Section A, Row 12, Seat 7) cannot be split or sub-bucketed like fungible inventory, so contention is unavoidable. We cover seat-level pessimistic holds with TTL, the virtual waiting room that randomizes queue position to absorb flash demand fairly, anti-bot defenses, dynamic pricing tiers, and the read-replica explosion that interactive seat maps cause.

design-ticketing-system
case-study
ecommerce-marketplace
ticketmaster
seat-reservation
flash-sale
virtual-waiting-room
pessimistic-locking
websockets
system-design
intermediate
premium

998

29

Medium
System Design

Design Uber / Lyft (Ride-Sharing)

Design a ride-sharing service like Uber that matches a rider's request to a nearby driver in under 5 seconds, streams driver locations every 4 seconds, computes ETAs, and applies surge pricing in real time at 1M concurrent active drivers and 100K rides/min globally. The interview centerpiece is the dispatch path: how to find the nearest available driver, hold them briefly, and confirm the match without race conditions. We compare geohash, S2, and H3 for the driver index and recommend H3 hex grid for ride-sharing because hex neighbors are equidistant. We cover the trip state machine, surge multipliers per cell, and how location updates fan out without melting the network.

design-uber
case-study
ride-sharing-and-maps
ride-sharing
uber
lyft
driver-dispatch
ride-matching
h3-hex-grid
geospatial
geospatial-index
geohash
s2-cells
surge-pricing
trip-state-machine
websockets
kafka
real-time-systems
system-design
intermediate
premium

285

9

Medium
System Design
Premium

Design Google Docs (Collaborative Editing)

Design a real-time collaborative document editor like Google Docs where 1B+ users can co-edit the same document with sub-200 ms latency, never lose a keystroke, and converge to the same state across all clients regardless of network conditions. The interview centerpiece is concurrency control: how to merge two users' simultaneous edits without conflicts. We compare Operational Transformation (OT, used by Google Docs) and Conflict-free Replicated Data Types (CRDT, used by Figma, Notion, Linear), explain the convergence problem (TP1, TP2 properties), walk through cursor presence, and design the document storage as an append-only operation log compacted into snapshots.

design-collaborative-editor
case-study
unique-specialized
google-docs
collaborative-editing
operational-transform
crdt
real-time-sync
websockets
presence
vector-clock
event-sourcing
consistency-models
system-design
advanced
premium

267

4

Hard