Live by default
Slack feels instant because each client holds a websocket to a messaging server. New messages, typing indicators, and presence push down that socket without polling.
Channel fan-out
A message posted to a channel must reach every connected member. The server looks up who is subscribed to that channel and fans out the event to each of their sockets.
- Clients connect via websocket to a gateway
- The server maintains channel subscriptions per connection
- A new message is pushed to all subscribed sockets
Ordering and history
Messages need a stable order. Each message gets a monotonic id within its channel, so clients can render in order and detect gaps. History is loaded from a durable store, while live updates arrive over the socket.
The realtime feel comes from pushing over persistent sockets, and correctness comes from per channel ordering.
Key idea
Hold a websocket per client, fan out each message to the channel subscribers, and assign a monotonic per channel id so everyone sees a consistent order.