Channel Fan-Out: Why Big Channels Are Expensive
The Naive Cost, and Why It's Only Half the Story
work per message = n recipients × (deliver + decide + record)
Every message posted in a channel with n members is n units of work. A 20-person channel: trivial. A 10,000-person #announcements: one keystroke by one person creates 10,000 units. That asymmetry — O(1) input, O(n) output — is the definition of a fan-out problem, and it is the same shape as Twitter's celebrity-tweet problem.
But the Gateway and Channel Servers part already showed the delivery half is better than it looks. The Channel Server does not write to 10,000 sockets; it writes one event to each Gateway Server that has a subscriber, and each GS expands locally:
The total socket writes are still 10,000, but no single machine does 10,000 of them, and none of them are network round trips to a database. Pure delivery fan-out is a solved problem. So where does the pain actually come from?
The Real Cost: Everything That Isn't Delivery
For each member of that channel, the system must also decide and record things that are per-user, not per-message. Note who this work is done for: every member, whether or not they are connected or subscribed — the tree above only flattens delivery to the people actually watching, and the Gateway and Channel Servers part covers how the result of this work then reaches someone who is not (their own user topic, or a push to their phone).
| Per-recipient work | Why it can't be shared across recipients | Where it lands |
|---|---|---|
| Unread count | Depends on each user's own last-read marker for this channel | Datastore write or read-modify-write |
| Mention detection | @alice is a mention for Alice and noise for everyone else; @channel is a mention for all n | Per-user badge state |
| Notification decision | Depends on that user's per-channel preferences, mute state, Do-Not-Disturb schedule, timezone, and which devices are active | Preference lookups per user |
| Mobile push | Users without an active desktop socket need APNs/FCM — a separate outbound request per device | External push provider |
| Thread / mention subscriptions | Each subscriber has their own subscription row | Rows, per user per thread (see async work) |
Delivery fans out one copy through a tree. Bookkeeping fans out n independent database interactions. The tree flattens the first; nothing flattens the second, which is why large channels hurt.
The Notification Storm
Now the specific failure the question names. Someone types @channel in a 10,000-member channel:
10,000 mention records — the message counts as a direct mention for every member, so every member's badge state changes.
10,000 notification decisions — each requires that user's preferences, mute settings, DND window, and device list. These are per-user lookups; nothing about them is cacheable across users.
Thousands of outbound push requests to APNs and FCM for members not actively connected — external calls, with their own rate limits, retries, and failure modes.
A human storm on top of the machine storm. Several hundred people react, reply, or post "who is this for?" — each of which is itself a message fanning out to 10,000. The response burst is frequently larger than the trigger.
How Slack Tames It
| Technique | What it actually reduces |
|---|---|
| Subscribe, don't broadcast | The subscriber list follows connections, not memberships. A Gateway Server registers with a Channel Server only on behalf of clients it actually holds — once per channel, however many of its clients belong to it — and a CS sends to a GS only if that GS has registered. A member who is not connected costs nothing: they are not skipped during fan-out, they were never in the subscriber list to begin with (the Gateway and Channel Servers part’s subscribe path shows how that list is built). For presence, Slack goes one step further and scopes the subscription to what is on screen (see presence). |
| Batching and coalescing | Grouping many small events into one frame. Slack does this explicitly for presence (batch_presence_aware, the presence part) and the pattern generalises: 50 events in one frame beats 50 frames. |
| Transient events skip persistence | Typing indicators and live document cursors use the identical routing path but are never written to MySQL. Same fan-out, none of the write cost — and if one is dropped, nothing is lost. |
| Thin events, fat objects | Push a compact event and let the client hydrate details from Flannel (see Flannel), rather than pushing a fully-expanded payload n times. The expensive bytes are sent once to a cache instead of n times over sockets. |
| Product-level guardrails | Restricting who may use @channel, warning dialogs on large channels, per-app API rate limits. Not an engineering fix — a decision to make the expensive operation harder to trigger accidentally. Entirely legitimate, and often the highest-leverage change available. |
| Move bots off sockets | The Events API (see Flannel) means an integration receives only the event types it subscribed to, over HTTP, instead of holding a socket drinking the firehose. |
The Second Delivery Path: Mobile Push
A connected client gets the message over its socket. A backgrounded phone does not have a usable socket, so it must be reached through APNs or FCM — a completely different channel, with different latency, different failure modes, and no delivery guarantee.
That creates a deduplication requirement: a user with a laptop and a phone must not get the same thing twice — and the two paths race. Slack's ts (the per-channel message ID) is what makes this tractable: both paths carry it, so the client can recognise "I have already displayed ts=1694612345.001200" regardless of which path delivered it first.
- Guarantees: Delivery fan-out cost is spread across the Gateway fleet rather than concentrated on the publisher, and members who aren't subscribed cost nothing at all.
- Does not guarantee: That the total work per message is bounded. Per-recipient bookkeeping and push decisions remain strictly O(n) and hit the datastore, so one message in one very large channel can still outweigh an entire small workspace's daily traffic.