Skip to content
← 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

Components involved

Related concepts