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:

MoveWhat it doesWhat it solves
ReplicationCopy 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.

Two bands. The allowed band shows Shard 3 as one box containing workspace T7 with 12 users, workspace T42 with 900 users, workspace T88 with 40 users, and a row of sixteen small unlabelled workspace tiles standing for about 3,000 more, all on that one shard; below it Shard 17, an identical machine, is filled entirely by workspace T91 with 50,000 users, which is legal but leaves no room and is the section 7 ceiling. The forbidden band shows Shard 4 and Shard 5 as two separate machines with a single dashed red box straddling both of them, labelled T91's channels and memberships on shard 4 and T91's messages and files on shard 5, with a red cross at the boundary: one workspace split across two shards cannot exist. A shard holds thousands of workspaces, but a workspace never spans shards.
Many workspaces per shard; never a workspace across shards

The Original Topology

Before Vitess, Slack ran three kinds of MySQL cluster:

ClusterContentsSharded by
ShardsCustomer data — messages, channels, memberships, files. Each shard held data for thousands of workspaces.Workspace ID
Metadata clusterThe workspace → shard lookup table. Every request consults this first.Not sharded — it's the directory
"Kitchen sink" clusterEverything 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.

A request arrives carrying team_id T42. One numbered arrow, labelled as the entire indirection, goes to the Metadata cluster, which is not sharded and maps T42 to shard 17; that table is small and rarely changes, so it caches perfectly. A single arrow then leads down into one large box, Shard 17, which contains all of T42's data: tiles for messages, channels, memberships, files and every other table, and inside them a green panel headed 'every query runs entirely in here' listing a join across messages, channels and memberships as an ordinary single-box join, a transaction spanning all three tables as an ordinary MySQL transaction, and export, delete, restore or relocate this customer as one bounded set of rows. Everything after the single lookup is drawn inside the shard: no scatter-gather, no cross-shard transaction, no distributed query planner.
One indirection, then everything is local

What Workspace Sharding Buys

  1. 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 memberships is 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.

  2. 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.

  3. 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.

  4. 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

CostMechanism
Hot shardsA 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 ceilingSlack 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 utilisationCapacity 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 couplingA 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 unusableRouting 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 burdenThe 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.