← All concepts
Messaging & flow
WebSockets & real-time push
Keep a persistent connection open so the server can push updates instantly.
Chat, live tracking and tickers can't wait for polling. Each client holds one long-lived connection to a gateway; the server pushes messages as they happen.
See it in action
Step through the scenarios on the diagram.
Laying out diagram…
1/6Alice sends 'hi' over her open socket.
- Alice
- — Connected to node 1
- Bob
- — Connected to node 2
- L4 load balancer
- — Spreads long-lived connections
- Gateway node 1
- — Holds Alice's socket
- Gateway node 2
- — Holds Bob's socket
- Connection registry
- — user → node
- Pub/sub bus
- — Node-to-node delivery
How it works
- A connection registry maps userId → gateway node.
- Gateways exchange messages over pub/sub so any node can reach any user.
- Heartbeats detect dead connections; clients reconnect with backoff.
Trade-offs
- Stateful servers: deploys and failures cause reconnect storms.
- Each node holds tens of thousands of sockets — needs async I/O and L4 load balancing.
Seen in
- WhatsApp / MessengerBillions of real-time messages per day
- UberReal-time ride matching at global scale
- DropboxFile sync across every device
- WebSockets at scaleMillions of live connections with Go on Kubernetes
- Video calling (WebRTC)1:1 and group calls with signalling, TURN and SFUs
- Airline reservationsFlights, seats, bookings and check-in for one airline
- NoBrokerBroker-free property rentals and sales
- Zomato / food deliveryRestaurant discovery, ordering and live delivery tracking
- Porter / goods deliveryBook a truck or bike to move goods across the city
- Driver booking & fleet managementHire a driver for your car, and run fleets of drivers and vehicles
- Practo / teleconsultationFind doctors, book appointments, consult over video
- AstroTalkPay-per-minute chat and calls with astrologers
- Stock brokerageLive quotes, order placement and portfolios
- Live sports scoresReal-time scores, commentary and alerts for millions