Channels Have One Home

Slack's real-time path has stateful channel servers, each owning a set of channels by consistent hash and holding recent history in memory (millions of channels per host at peak), and stateful gateway servers that hold the client websockets. Gateway servers are deployed in several geographic regions so clients connect nearby; channel servers are not replicated per region. Messages flow client, webapp, admin server, the owning channel server, then out to every subscribed gateway.

Why keep the websocket tier regional but the channel tier single-homed per channel?

A

Websockets have to terminate in the same region as the channel server that owns the channel they subscribe to.

B

Every message in a channel passes through the one server that owns it, which is what makes a single order exist for that channel. Regional copies would have to agree on that order before a sender could be told the message landed.

C

Channel servers hold too much state to replicate: millions of channels per host means a regional copy would not fit in memory.

D

A consistent hash ring cannot span regions, so channel ownership has to stay inside one region.