Real-time Messaging

This post details the architecture for real-time messaging at Slack, focusing on the core services: Channel Servers (stateful, in-memory, serving subsets of channels via consistent hashing), Gateway Servers (stateful, in-memory, multi-region, client interface), Admin Servers (stateless, in-memory, webapp to CS interface), and Presence Servers (in-memory, user online status). It describes the client websocket setup, message broadcasting flow from client to Webapp, AS, CS, and then to multiple GSs and clients, and the handling of events, including transient events like typing indicators. The system achieves linear scalability to serve tens of millions of channels per host and tens of millions of connected clients, delivering messages globally within 500ms.