End-to-end flow (high level)
- Client → API/web server: Paul’s Slack client sends an API request (POST) to a web server.
- Auth & persist: The web server authorizes the request and persists the message in a sharded MySQL store.
- Routing: A proxy/routing layer (Vitess) directs the write to the correct shard for that channel.
- Delivery layer: The web server forwards the saved message to Slack’s delivery (admin/broker) layer.
- Channel server → Gateways: The responsible channel server fans the message out to subscribed gateway servers.
- Gateways → Clients: Each gateway pushes the message over existing WebSocket connections to its connected clients.
Components at a glance
Client -> Web server -> Sharded storage
When Paul sends a message, his client calls Slack’s API endpoint on a web server. The server:- Authenticates Paul and validates his permission to post in that channel.
- Persists the message to storage so conversation history is durable.

Delivery layer: channel servers and gateways
After a successful write, the web server forwards the message to Slack’s delivery layer (sometimes called the admin or broker layer). The delivery layer’s two primary responsibilities are:- Determine which channel server currently owns the channel.
- Ensure that channel server notifies the appropriate gateway servers.

Gateways, WebSockets, and subscription model
Slack deploys gateway servers in multiple regions so users connect to a nearby gateway for lower latency. When a Slack client opens, it typically establishes a persistent WebSocket to a regional gateway. That connection stays open so the gateway can push events (new messages, typing indicators, presence updates) directly. Gateways subscribe to the channel servers for the channels that have connected users. A subscription acts like a short-lived interest registration: “I’m hosting users who are in channel X; send me updates for X.” For example:- Alan (London) connects to a local gateway. Because Alan is a member of #marketing, that gateway subscribes to the Marketing channel server.
- Other gateways subscribe similarly for their connected members.

Fan-out efficiency: one-to-many + many-to-individual
This two-layer fan-out keeps the system efficient:- Channel server → gateway: One message per subscribed gateway.
- Gateway → clients: The gateway handles per-client deliveries across its WebSocket pool.

Delivery guarantees and offline clients
- Live push: If a client has an active WebSocket to a gateway, it receives events pushed in near real time.
- Offline or closed client: If the client is not connected, it will not receive live pushes. Messages are still persisted and are available when the client next syncs.
If a user’s Slack client is closed (no active WebSocket), they will not receive the live push. Their message history is still stored in the database, and when they reopen Slack their client will fetch missed messages (via history/sync APIs) or reestablish a WebSocket and receive any undelivered events from the gateway/channel-server sync mechanism.
Operational considerations (brief)
- Regional gateways reduce latency and concentrate WebSocket state closer to users.
- Sharding by channel ID reduces cross-channel contention and lets storage scale horizontally.
- Using a routing/proxy layer like Vitess simplifies scaling MySQL clusters and hides sharding complexity from application servers.
- The subscription model reduces unnecessary traffic: only gateways with active members for a channel receive updates.
Links and references
- Vitess: https://vitess.io/
- WebSockets (MDN): https://developer.mozilla.org/en-US/docs/Web/API/WebSockets_API
- MySQL: https://www.mysql.com/