Skip to main content
How does Slack deliver a single message to thousands of people around the world in near real time? Imagine a channel with 10,000 members. Paul (in India) posts a message and teammates in London and New York see it almost instantly. Below is a concise, step-by-step explanation of the systems and components that make that possible, followed by notes about delivery guarantees and client behavior.

End-to-end flow (high level)

  1. Client → API/web server: Paul’s Slack client sends an API request (POST) to a web server.
  2. Auth & persist: The web server authorizes the request and persists the message in a sharded MySQL store.
  3. Routing: A proxy/routing layer (Vitess) directs the write to the correct shard for that channel.
  4. Delivery layer: The web server forwards the saved message to Slack’s delivery (admin/broker) layer.
  5. Channel server → Gateways: The responsible channel server fans the message out to subscribed gateway servers.
  6. 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.
Slack scales storage by sharding data across many MySQL instances. Channel-scoped data is sharded by channel ID (e.g., #marketing on shard 2, #sales on shard 7). Between the web servers and MySQL sits Vitess, which inspects queries and routes them to the correct shard.
A dark-themed illustration showing messages from a #marketing channel routed through an API/web server into a Vitess layer and three MySQL shards. Cartoon user avatars with location labels (New York, London, India) appear along the right side.
Persistence ensures messages are available for history and sync, but storing the message is only one part of real-time delivery.

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.
There are many channel servers so Slack can distribute ownership across millions of channels. Each channel server is responsible for a subset of channels (for example, Channel Server 1 may own the Marketing channel).
A dark-themed system diagram showing an admin server labeled "#marketing" routing messages into "Channel Server 1" with a highlighted message bubble. Avatars and location labels (Paul, New York, London, India) and gateway icons along the right suggest delivery to different user endpoints.

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.
When the channel server receives Paul’s message, it forwards the message only to the gateways that subscribed. Each gateway then distributes the message to all clients connected to it via their open WebSocket connections.
A dark world map showing three highlighted gateway boxes labeled "Gateway US", "Gateway Europe" and "Gateway Asia." Small user icons mark locations on the map and circular profile avatars with city labels (New York, London, India) appear along the right side.

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.
For example, a gateway with 2,000 connected users who are members of Paul’s channel only receives a single forwarded message from the channel server and performs the 2,000 individual WebSocket writes itself. This design reduces cross-datacenter and cross-service traffic and keeps channel servers from managing enormous per-client state.
A dark-themed diagram showing a chat flow from a user avatar labeled "Paul" through channel servers and a Europe gateway. On the right, a dense grid of yellow dots visually represents 2,000 deliveries.

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.

Watch Video