DEV Community

Cover image for Design Slack: the team-messaging system design interview walkthrough
Gowtham Potureddi
Gowtham Potureddi

Posted on

Design Slack: the team-messaging system design interview walkthrough

Design Slack: the team-messaging system design interview walkthrough

The request to design Slack looks like a chat app you have built before — type a message, store it, show it to the other person. For a one-to-one DM that is exactly what it is. But the interview asks you to do it for a workspace: hundreds of channels, a message that has to reach every one of a channel's members at once, threaded replies hanging off any message, and full-text search over years of history that must never leak a private channel. That is a fan-out and search problem, not a message box — which is why team chat system design is a different round from the one-to-one chat prompt, even though both start with "send a message."

The round turns on two decisions that a DM design never forces. First, fan-out: when someone posts in a channel, how does that single write reach ten, or ten thousand, connected members without you flooding your own servers? Second, retrieval at scale: how are a channel's messages stored so that threads, two years of scroll-back history, and a search box all stay fast — and how does search refuse to return a message from a private channel the asker was never in? This walkthrough follows the path a strong candidate draws on the whiteboard — requirements, estimate, API and data model, high-level design, then the deep dives — and at each step it names the follow-up the interviewer uses to tell a memorised answer from an engineer who understands the tradeoff.

Title card for a system design interview walkthrough on designing Slack, showing a message posted to a channel fanning out through a WebSocket gateway to many connected members on a dark citrus-and-lavender background.

How the team-messaging round is actually run

The closest live version of this on Zynter is the Meta · Chat Messenger (WhatsApp) HLD round — "Messaging & realtime", about 45 minutes on a shared canvas. You draw the boxes and arrows while you talk, and the interviewer interrupts. The team-messaging framing pushes it harder than a one-to-one chat: the moment you write "post to a channel," the question becomes who is connected, how do they all find out, and how do you not fall over when the channel has twenty thousand people in it — and every answer after that (fan-out, storage, search, permissions) compounds.

The interviewer rarely lets "save the message and show it to everyone" stand. "You've got a channel open and a teammate types — how does their message reach your screen without you refreshing, and how does the server even know where to send it?" That question — realtime delivery through a connection you have to track — is the one a copied answer can never rehearse, and the one this round is really testing.

The rounds here are modelled on how the loop runs, not scraped from any candidate's recall. What matters for prep is the shape: a blank canvas, a clock, and a follow-up after every decision you make.

The five-step framework for any HLD round

Every high-level design answer fits the same spine. Say it out loud at the start so the interviewer knows you have a plan, then walk it:

  1. Clarify requirements — functional and non-functional, and what you are explicitly not building.
  2. Estimate — users, message rate and fan-out, to justify every later choice.
  3. High-level design — the boxes and arrows: client, WebSocket gateway, messaging service, store, fan-out, search.
  4. Deep dive — the two or three decisions that actually decide this system.
  5. Follow-ups — bottlenecks, failure modes, and what you would change at ten times the scale.

What the debrief measures

The score is not "right or wrong design." A good HLD debrief reads on four dimensions, and every move below maps to one: problem solving (did you make fan-out scale down to a DM and up to a 20,000-person channel with the same model), communication (did you say why you push to online members and pull for the rest in one sentence), technical execution (shard messages by channel, paginate history by timestamp, index search per workspace with a permission filter), and time management (did you spend your 45 minutes on fan-out, storage and search, not on the emoji picker). Reading a walkthrough teaches the design; it does not teach you to deliver it on the clock while someone pushes back.

Step 1 — Requirements: what a team-messaging app must do

Spend the first few minutes here. Jumping to boxes before you have scoped the problem is the fastest way to design the wrong system.

Type Requirement
Functional Workspaces that contain channels (public and private); post a message to a channel; deliver it in realtime to every connected member; threaded replies off any message; @mentions that notify a user; full-text search over a workspace's history; presence (who is online).
Functional (optional) File sharing and uploads, reactions, read receipts, message edits/deletes, cross-workspace shared channels — call these out, then scope most of them (file sharing especially) for later.
Non-functional Low-latency delivery (feels instant); huge per-message fan-out (one post to a 20,000-member channel); read-heavy history (scroll-back far outweighs sends); search that is fast and permission-correct; highly available; durable (a delivered message is never lost).

The sentence that earns points: "A one-to-one chat is a solved problem — the hard part of team messaging is that one write has to fan out to thousands of connections, and the whole history has to stay searchable without ever leaking a private channel." Say that and you have framed the entire design before drawing a box.

Step 2 — Capacity estimation (back of the envelope)

Estimation here is about proving one thing: the hard axis is fan-out and retrieval, not raw message volume. There are fewer users than a consumer messenger, but each message does far more work.

Quantity Assumption Result
Daily active users ~10M DAU ~2–3M concurrent WebSocket connections at peak
Messages sent ~50 msgs/user/day → ~500M/day ~6K message writes/sec average, higher at peak
Fan-out avg delivery ~50 members, big channels up to 20K writes are modest; deliveries are 10–100× the write rate
History + search ~500M msgs/day × ~1KB ~180TB/year of messages → sharded store + a smaller inverted index

Two conclusions fall out, and you should say both out loud. First, the write rate is small but the delivery rate is not — a single post to a large channel is one database write and potentially twenty thousand pushes, so fan-out is the scaling axis, not ingestion. Second, the data is read-heavy and long-lived — people scroll back and search far more than they send, so storage has to be cheap, sharded for fast per-channel reads, and separately indexed for search. You have now pointed the interview at the real deep dives before anyone asked.

Step 3 — API and data model

The client talks to the server two ways: a WebSocket for realtime send/receive, and ordinary request/response for history and search. The interface is that pair of contracts plus the tables that hold channels, membership and messages.

Call Operation
ws.connect(user_id) open a persistent connection; the gateway registers user → connection server
sendMessage(channel_id, body, parent_ts?) → ts persist a message (optionally as a thread reply), then fan out
getChannelHistory(channel_id, before_ts, limit) → messages[] paginate scroll-back by timestamp
search(workspace_id, query) → messages[] full-text search, filtered to channels the caller can see

The data model is organised around the channel as the shard key:

Entity Notes
workspace top-level org: workspace_id, name, members.
channel channel_id, workspace_id, name, type (public/private), created_at.
membership (channel_id, user_id) plus last_read_ts — drives who to fan out to and the unread badge.
message channel_id (shard key), ts (ordering), sender_id, body, thread_parent_ts (null for top-level).
search_index an inverted index (e.g. Elasticsearch), partitioned by workspace_id, carrying channel_id for permission filtering.

Step 4 — High-level design: the delivery loop

Now the boxes. The whole system is a message posted on one connection reaching the right set of other connections, with everything persisted and indexed on the way:

  • Client ⇄ WebSocket gateway: a pool of connection servers that hold millions of persistent WebSocket connections and keep a registry of user_id → connection server (in Redis) so the system knows where each online user is.
  • Messaging service: receives a send, writes it to the channel message store, then hands it to fan-out. Nothing is "delivered" until it is durably stored.
  • Channel message store: messages sharded by channel_id and ordered by ts, so all of a channel's history is colocated and a scroll-back is a single clustered read.
  • Fan-out service: looks up the channel's membership, finds which members are online via the connection registry, and pushes the new message to each member's connection server.
  • Search service: an inverted index fed by an async indexing pipeline, so every stored message becomes searchable without slowing the send path.
  • Notification service: turns @mentions and messages to offline users into push/email, and updates unread badges.
  • Presence service: tracks who is online from the connection servers' heartbeats.

Say explicitly that store-then-fan-out is the invariant — you persist before you deliver, so a message is never shown to one member and lost for another. Naming that ordering unprompted is a signal the interviewer is listening for.

A team-messaging architecture diagram showing clients connected to a pool of WebSocket gateway connection servers, a messaging service that writes to a channel message store sharded by channel_id, a fan-out service that pushes to online members via a connection registry, a search service with an inverted index fed by an async indexer, and notification and presence services.

Deep dive: channel fan-out

This is the first decision that actually decides the round, and it is the one a one-to-one chat never makes you solve. When someone posts, the message is already stored; fan-out is the job of getting it onto every member's screen. For a small channel you do the obvious thing — fan-out on write: read the membership, look each member up in the connection registry, and push the message to the connection server holding their socket. Offline members get nothing now; they will read it from history on reconnect, and their unread count is bumped.

The problem is the big channel. Pushing synchronously to twenty thousand members on the send path would make one person's message block on twenty thousand lookups and writes. The senior answer splits by channel size.

Channel size Strategy Why
Small / normal fan-out on write to all online members Delivery is cheap; everyone sees it instantly; simplest path.
Large (thousands+) push only to actively-viewing members, hand the rest to an async queue, and let non-viewers pull on open A post to a 20K channel becomes a few hundred live pushes plus a cheap unread signal, not 20K synchronous writes.

The flow for a large channel: the message is stored, the fan-out service pushes to the small set of members who currently have the channel open, enqueues the rest for background unread-badge updates, and anyone who opens the channel later simply reads recent history. @mentions are the exception that always escalates — a mention goes through the notification service to push/email even an offline user, because a mention is worth waking someone for.

"Someone posts in a 20,000-person channel — do you push to everyone at once?" No. You push live only to members actively viewing the channel, update an unread badge asynchronously for everyone else, and let them pull the message when they open it; mentions alone get a real notification. Say both halves — most candidates describe fan-out on write and forget it falls over on the biggest channels.

System Design
HLD · Messaging & realtime · 45 min
Design Slack's channel fan-out out loud, with follow-ups

Practise on Zynter →

Deep dive: message storage, threads and history

This is the decision most candidates under-think. The send is easy; the follow-ups are always "where do a channel's messages live?" and "how does someone scroll back two years without a slow query?"

Sharding by channel. Messages are stored in a wide, write-heavy store (a Cassandra-style wide-column DB or a sharded relational store) with channel_id as the shard/partition key and ts as the clustering key. Everything a channel has ever said is colocated and already ordered, so loading a channel or scrolling it is a single contiguous read — never a scatter-gather across shards. A hot channel's traffic stays on its own partition rather than hammering one global table.

Threads. A threaded reply is just a message with a thread_parent_ts pointing at the message it answers. A thread is then "the parent plus every message whose thread_parent_ts equals the parent's ts" — same channel shard, a cheap secondary read. You do not need a separate threads table; the parent pointer on the message is enough, and it keeps replies on the same shard as their channel.

History and pagination. Scroll-back uses keyset (cursor) pagination by timestamp — getChannelHistory(channel_id, before_ts, limit) — not OFFSET, which gets linearly slower the further back you go. Older history is tiered into cheaper cold storage behind the same API, so two years of scroll-back is a bounded, indexed read regardless of depth. Ordering is kept correct with a server-assigned timestamp/sequence per channel, so two near-simultaneous posts get a deterministic order everyone agrees on, rather than trusting client clocks.

"A user scrolls up two years of history — how is that paginated and stored?" Messages are sharded by channel_id and ordered by ts, so history is a clustered read; the client pages with a before_ts cursor (keyset pagination, not offset), and old partitions tier into cold storage behind the same call — so depth of scroll-back does not degrade the query.

A message storage and threads diagram showing a channel message store partitioned by channel_id and ordered by ts, a thread modelled as a parent message with replies carrying thread_parent_ts, keyset pagination with a before_ts cursor over recent and cold-tier partitions, and a server-assigned sequence that fixes ordering of near-simultaneous posts.

System Design
HLD · Storage & history · 45 min
Defend message storage, threads and scroll-back out loud

Practise on Zynter →

Deep dive: full-text search

Search is where team messaging diverges hardest from a DM app, and it is the deep dive with a trap built in. A channel store sharded by channel_id and ordered by ts is perfect for reading one channel and useless for "find every message that says deploy across the workspace" — that query would scatter across every shard. So search needs its own structure: an inverted index (e.g. Elasticsearch) that maps each term to the messages containing it.

Indexing pipeline. You never index on the send path. On every message write, the messaging service publishes the message to a stream (e.g. Kafka); an indexer consumes that stream asynchronously and updates the inverted index. Search is therefore eventually consistent — a message is searchable a second or two after it is sent — which is the right tradeoff, because nobody expects to search a message the instant they type it, and the send path stays fast.

Scoping and permissions — the trap. Two filters sit on every query. The index is partitioned by workspace_id, so a search only ever touches one workspace's data. And because the index carries each message's channel_id, the query is filtered to the set of channels the asker is a member of before results are returned — public channels in their workspace plus the private channels they belong to. A message from a private channel the user is not in is removed at query time, so it can never surface in results. Getting this filter wrong is the single worst bug in the design: it leaks private conversations.

"Search must never return a message from a private channel the user isn't in — how do you enforce that?" The inverted index stores each message's channel_id, and every search is filtered at query time to the channels the asker is a member of — public channels plus their private memberships — so a private-channel message the user cannot see is excluded before results are returned, not hidden in the UI afterwards.

A full-text search diagram showing messages published to a stream and consumed by an async indexer into an inverted index partitioned by workspace_id, a search query filtered by the asker's channel memberships so private-channel messages they do not belong to are excluded at query time, returning only permitted results.

The follow-ups that decide the team-messaging round

Scan the probes from each deep dive and they rhyme. Master these five and you are ready for a version of the question that is not drawn exactly like this one.

  • "How does a teammate's message reach your screen without a refresh?" → A persistent WebSocket through a connection server, with a user → connection registry the fan-out service pushes to. (communication)
  • "Do you push to everyone at once in a 20,000-person channel?" → No — push live to active viewers, async unread badge for the rest, pull on open; mentions alone get a real notification. (problem solving)
  • "How is two years of history paginated and stored?" → Sharded by channel_id, ordered by ts; keyset pagination by before_ts; old partitions tiered to cold storage. (technical execution)
  • "How are threads modelled?" → A reply is a message with a thread_parent_ts pointer, living on the same channel shard — no separate table. (technical execution)
  • "How does search never leak a private channel?" → An inverted index partitioned by workspace, filtered at query time to the channels the asker is a member of. (problem solving)

Each maps to a debrief dimension. Reading this list teaches you the answers; it does not teach you to deliver them while someone interrupts — that only comes from saying them out loud.

How to prepare: a one-week plan

You do not need fifty systems. You need this one cold and the framework automatic, so the next "design X" is just new nouns in the same five steps.

  • Days 1–2: Learn the five-step framework until it is reflex. Do Slack end to end on paper — requirements, estimate, data model, the client → gateway → messaging service → store → fan-out loop.
  • Days 3–4: Drill the fan-out deep dive: fan-out on write for small channels, push-to-viewers-plus-pull for big ones, mentions through notifications. Say each tradeoff in one sentence.
  • Days 5–6: Own storage and search — channel sharding, thread pointers, keyset pagination, the async inverted index, and the permission filter that keeps private channels private. Answer each of the five follow-ups out loud.
  • Day 7: A full timed 45-minute round, narrating the whole way, with someone (or something) interrupting. This is the rep that counts.

This post is the deep walkthrough behind one row of the broader system design interview questions — once Slack is automatic, the same spine carries the rest of the list.

Frequently asked questions

How do I design Slack step by step?

Follow the five-step HLD framework. Clarify requirements (workspaces, channels, realtime delivery, threads, @mentions, full-text search, presence; scope out file sharing); estimate to show the hard axis is fan-out and retrieval, not message volume; define the WebSocket plus request/response contracts and the workspace, channel, membership, message and search-index tables; draw the delivery loop (client → WebSocket gateway → messaging service → channel store → fan-out, with search and notification services); then deep-dive the decisions that matter — channel fan-out, message storage and threads, and permission-aware full-text search.

How does channel fan-out work in a team-messaging system?

When a message is posted it is stored first, then fanned out. For a normal channel you fan out on write: look up the members, find who is online in the connection registry, and push the message to each member's connection server. For a very large channel you do not push to everyone synchronously — you push live only to members actively viewing the channel, update an unread badge asynchronously for the rest, and let them pull the message when they open it. @mentions always escalate to a real notification through the notification service, even for offline users.

How are messages and threads stored in Slack's design?

Messages live in a write-heavy, horizontally sharded store with channel_id as the shard key and ts as the clustering key, so a channel's whole history is colocated and already ordered — loading or scrolling a channel is one contiguous read. A threaded reply is simply a message carrying a thread_parent_ts that points at the message it answers, so a thread is the parent plus every reply with that parent timestamp, on the same shard. No separate threads table is needed.

How does scroll-back history stay fast over years of messages?

Because messages are ordered by timestamp within each channel's shard, history is a clustered read, and the client pages with keyset (cursor) pagination — getChannelHistory(channel_id, before_ts, limit) — rather than OFFSET, which slows down the further back you go. Older partitions are tiered into cheaper cold storage behind the same API, so two years of scroll-back stays a bounded, indexed read no matter how deep a user scrolls.

How does full-text search avoid leaking private channels?

Search runs on an inverted index (such as Elasticsearch), kept up to date by an async indexer that consumes a stream of new messages, so indexing never slows the send path. The index is partitioned by workspace_id, and every query is filtered at query time to the channels the asker is a member of — public channels plus their private memberships — using the channel_id stored on each indexed message. A message from a private channel the user is not in is excluded before results are returned, never merely hidden in the UI.

How do I practise a system design interview out loud?

Reading a walkthrough is not the same as defending a design while someone interrupts. On Zynter, the HLD track runs live voice rounds modelled on how real system design loops run — you talk through a shared design on the canvas, and a voice interviewer pushes with the follow-ups above one at a time, then gives you a debrief on problem solving, communication, technical execution, and time management. The score is a practice signal, not a hiring decision.

Practise it on Zynter

You can read every hop. The round is won on fan-out and the private-channel search case.

Pick the Chat Messenger round, draw the delivery loop on the canvas, and defend it out loud to a voice interviewer that keeps asking "do you push to all twenty thousand at once?" and "how does search never leak a private channel?" — then read the debrief. Zynter.ai is on-demand mock interviews modelled on real company loops, with 150+ rounds across 20 companies including the HLD system design track (Sep 2026).

Practise the team-messaging round →
Browse all interview tracks

Top comments (0)