Sharding by Workspace: Perfect Isolation, Hard Ceiling
"Shard" — What the Word Actually Means
One database server can only hold so much: so many rows on its disks, so many queries per second through its CPUs, so much working set in its RAM. When a dataset outgrows one machine there are exactly two moves, and they are often confused:
| Move | What it does | What it solves |
|---|---|---|
| Replication | Copy all the data onto more machines. | Read throughput and failure survival. Does nothing for size or write volume — every replica still holds everything and applies every write. |
| Sharding (horizontal partitioning) | Cut the rows into disjoint subsets and put each subset on a different machine. Each subset — and, loosely, the machine holding it — is a shard. | Size and write volume. Ten shards means each machine holds roughly a tenth of the rows and takes roughly a tenth of the writes. |
The entire design question in sharding is the shard key: which column decides where a row goes. The rule is mechanical — shard = f(shard_key) — and the consequence is severe: a query that knows the shard key touches one machine; a query that doesn't must ask every machine and merge the answers (a "scatter-gather"), and a transaction or JOIN spanning two shards needs distributed machinery that plain MySQL does not have.
So picking a shard key is really picking which questions stay cheap forever. Slack picked team_id — the workspace — because virtually every question Slack asks already carries one.
The Original Topology
Before Vitess, Slack ran three kinds of MySQL cluster:
| Cluster | Contents | Sharded by |
|---|---|---|
| Shards | Customer data — messages, channels, memberships, files. Each shard held data for thousands of workspaces. | Workspace ID |
| Metadata cluster | The workspace → shard lookup table. Every request consults this first. | Not sharded — it's the directory |
| "Kitchen sink" cluster | Everything that isn't workspace-specific — global tables that have no natural tenant (the account that maps one human to their several workspaces, for example: the thing consulted at sign-in, before any team_id is known). | Not sharded |
Each shard was two MySQL instances in different datacenters, asynchronously replicated, active-active — both sides able to accept reads and writes. That is an unusual choice (most shops run one writable primary), and it bought availability during a datacenter loss. What kept it sane in normal operation is that the application “will always prefer to query one of the two sides based on a simple hashing algorithm” — so a given workspace's traffic lands on one side and the other is a warm standby, and conflicting concurrent writes are a failover-window problem rather than an everyday one.
What Workspace Sharding Buys
-
Every query is single-shard — including joins. This is the enormous, underrated win. Because all of a workspace's data co-locates,
JOIN messages ON channels ON membershipsis an ordinary MySQL join on one box. No scatter-gather, no cross-shard transaction protocol, no distributed query planner. Slack kept a normal relational model at scale by making the relational unit the tenant. -
Blast radius equals one shard. A runaway query, a corrupted table, a bad migration — it takes down the workspaces on that shard and touches nobody else. Compare a globally-sharded design where a hot key can degrade the cluster for everyone.
-
Tenant operations become file operations. "Export this customer's data," "delete this customer under GDPR," "move this customer to EU infrastructure for data residency," "restore this customer to yesterday" — each is a bounded operation on a known set of rows on one machine, rather than a hunt across a global dataset. This is a compliance superpower, not just a performance one.
-
Routing is trivial and cacheable. One lookup, then you know where everything is for the rest of the request. The metadata table is small and changes rarely, so it caches perfectly.
What It Costs
| Cost | Mechanism |
|---|---|
| Hot shards | A shard holds thousands of workspaces, but load is wildly uneven. One enterprise customer with tens of thousands of users pins an entire shard while neighbouring shards idle. You cannot split the load, because splitting means splitting a workspace — which the model forbids. |
| A hard ceiling | Slack states the question plainly: "What if a single team and all of their Slack data doesn't fit our largest shard?" There is no incremental answer. Not a slow degradation — a wall. |
| Poor utilisation | Capacity must be provisioned for each shard's peak, and peaks don't align across shards. The fleet is sized for a sum of maxima it never actually experiences. |
| Availability coupling | A shard outage means total Slack unavailability — not degraded, not read-only — for every workspace on it. The isolation that protects others offers no redundancy to the affected. |
| Read replicas unusable | Routing logic was coupled to the application, so the app could not safely direct reads to replicas without a rearchitecture. Free read capacity sat on the table. |
| Custom operational burden | The active-active setup was non-standard MySQL, requiring bespoke tooling for failover, backup, provisioning, and topology — all of which Slack had to build and keep alive itself. |
- Guarantees: Every query for a workspace is answerable on one machine with ordinary SQL, including multi-table joins and transactions — and one tenant's failure, migration, or deletion is structurally invisible to every other tenant.
- Does not guarantee: That a workspace fits. Once a single tenant exceeds one machine's capacity there is no incremental remedy, and every feature that needs data from two workspaces at once has no shard to run on.