A message in #general, end to end
The app sends the message to the API, which stores it in the channel’s shard with the channel’s next number and only then confirms it. The API hands it to the channel’s server.
The channel’s server sends one copy to each gateway with members of the channel online, and each gateway writes it to those members’ sockets.
- Asha sends with her app’s message id.
- The API stores it with #general’s next number.
- The channel’s server sends it to each subscribed gateway.
- Each gateway writes it to its members’ sockets.
Diagram as text
Components: Asha’s laptop (Client); Messages API (Service); Channel’s shard (SQL DB); Channel server (Service); Gateway, Mumbai (API gateway); Gateway, London (API gateway); Members online (Client). Connections: Asha’s laptop → Messages API (send, with its own id); Messages API → Channel’s shard (next number); Messages API → Channel server (stored); Channel server → Gateway, Mumbai; Channel server → Gateway, London; Gateway, Mumbai → Members online (sockets).
Read:Learn: Real-time delivery architectureLearn: Consistency trade-offs
Check yourself
Why store before handing the message to the channel’s server?
Show answerHide answer
So that a crash can’t leave a message some people saw and nobody can scroll back to.