Skip to content
StackDecode
System Design
20. System Design Case StudiesAnimated

Distributed Chat Application

Chat rooms across many servers.

The idea

Gateways hold sockets, and pub/sub passes messages between servers.

Watch it work

Press play, pause, or step through. Some animations have settings you can change.

UsersWebSocket gatew…Pub/sub busMessage DBPresence
  • client
  • gateway / proxy
  • service
  • cache
  • data store
  • queue / stream

Users connect to any gateway over WebSockets.

step:
1/4
at:
Users
1/9

The green dot is a request moving through the system.

Step by step

  1. 1Client connects to a gateway
  2. 2Sends a message
  3. 3Pub/sub routes it to the right gateways
  4. 4Recipients receive it

Where it is used

Slack-like systems.

Watch out for

Presence and ordering across servers.

Related