wtf( )unctionsystem design, drawn
← all problemsWebSocketsHard

The message that only reached half the room

A chat app runs on three gateway servers. Clients hold long-lived WebSocket connections, spread across all three by the load balancer.

When someone posts to a room, everyone connected to THAT server sees it instantly and nobody else does. Each server can only push to sockets it is personally holding — and it has no idea the other servers exist.

Insert the component that carries a message from one gateway to all the others.
Components — tap one, then tap a slot on the diagram
!Someone posted to a room. A third of the people in it saw it.

Boundaries, outermost first: Gateway tier · stateful: Gateway 3 (holds C; FAILED: never saw it), Gateway 1 (holds A; FAILED: never saw it), Gateway 2 (holds B) Outside every boundary: Client C, Client A, Client B, an empty slot for the between the gateways Connections: Client A holds an open connection to Gateway 1 — WebSocket Client B holds an open connection to Gateway 2 Client C holds an open connection to Gateway 3 Gateway 2 publishes to between the gateways — publish (step 1) between the gateways publishes to Gateway 1 — to every node (step 2) between the gateways publishes to Gateway 3

Client C
Client A
Client B
Gateway 3holds Cnever saw it
Gateway 1holds Anever saw it
Gateway 2holds B