The Cross-Shard Wall: Vitess, Slack Connect, Enterprise Grid

Why Every Cross-Workspace Feature Hurts

A shared channel — two companies, one conversation — asks a question the schema has no way to answer:

QuestionWhy workspace sharding can't answer it
Which shard stores the messages?Workspace A's shard and workspace B's shard are different machines. Picking one makes the other's members permanently cross-shard for their own conversation.
Whose retention policy applies?A deletes after 90 days, B keeps forever. The row lives in one place but is governed by two policies.
Whose search index contains it?If indexes are partitioned by workspace, as the database was (see search), a message visible to two workspaces must be findable from both.
Whose admin can delete it? Whose compliance export includes it?Both, for their own members — which means per-member, not per-row, authority.
What does a JOIN do?The single-shard join that made everything simple in the workspace sharding part now spans machines, and there is no cross-shard transaction.

Enterprise Grid is the same problem from the other direction: one organisation made of many workspaces, with channels and users that span them. Slack states this directly — Enterprise Grid and Slack Connect "challenged the assumption that workspace data should live on a single shard, forcing workarounds and performance penalties."

Re-read that: not "were slow," but challenged the assumption. The constraint was never capacity. It was that one shard per workspace was baked into the application's idea of where data lives, so a feature that violated it had nowhere to run.

Why They Chose Vitess

Slack evaluated NoSQL and NewSQL and stayed with MySQL — years of operational muscle, tooling, and developer confidence are not worth discarding. The tempting alternative, building sharding logic into the application, failed on three counts:

  • Application logic and storage assumptions were already tightly coupled — the thing you'd have to untangle is the thing you'd be rewriting.
  • It fixes nothing operational: failover, backups, provisioning, and topology management stay bespoke and manual.
  • It offers no path for write-heavy hot shards, which was the actual emergency.

Vitess — MySQL underneath, a proxy tier (vtgate/vttablet) that owns sharding above — addressed all three: sharding decoupled from application logic, automatic failover and backups, open source and extensible.

The names, since the guide uses them. A keyspace is Vitess's unit of a logical database — Slack defines it as “a logical collection of data that roughly scales by the same factor” — and a keyspace is what gets sharded. vtgate is the stateless proxy the application talks to as if it were one MySQL: it holds the sharding rules, routes each query to the right shard or shards, and scatter-gathers when it must. vttablet is the sidecar on every MySQL instance that vtgate talks to; it also owns backups, replication management and failover for that instance. The sharding rules live in a VSchema: per table, which column is the shard key and how it maps to shards (a vindex). That is the concrete meaning of “sharding decoupled from application logic” — the key is declared in the VSchema, not computed in Hack code. VReplication hooks into MySQL replication to materialise a different view of the data; Slack calls out investing in it, and it is what makes resharding an online operation. (Slack's post names keyspaces and VReplication; the rest is Vitess's general architecture.)

The Migration — Deliberately Unglamorous

  1. Prototype end-to-end on something that doesn't matter. Slack's first Vitess workload was a small RSS feed feature. Not the message store. The point was to exercise the entire operational surface — provisioning, service discovery, backups, topology — on a workload whose failure nobody would notice.

  2. Build generic backfill with double-writes. A reusable system to clone a table into Vitess while both stores take writes, so tables could be migrated one at a time by different teams — rather than one heroic cutover.

  3. Verify with parallel double-read diffing. Read from both stores, compare results, and confirm semantic equivalence before trusting the new path. This is what makes double-write migrations safe: the diff is the test, and it runs on production traffic.

  4. Then move the shard key. With sharding out of the application, message data could be re-sharded by channel ID instead of workspace ID — in Slack's words, “instead of putting all the messages from every channel and DM on a given workspace into the same shard, we wanted to shard the message data by the unique id of the channel.” A huge customer's load is spread across the whole fleet instead of pinned to one host. The bill is stated in the invariants below: a query shaped like “everything for workspace T42” — export, deletion, a residency move — now touches every shard holding one of T42's channels. Vitess's general answer is a lookup vindex, a secondary table mapping a non-shard-key column to the shards that hold it, so the scatter is bounded rather than total; whether Slack uses one here is not published.

Two columns on identical geometry, differing only in the declared shard key. Left, BEFORE, shard key equals workspace_id: workspace ACME and workspace VENDOR each point down into their own machine, shard A holding all of ACME's data and shard B all of VENDOR's, and the shared channel #deal-room is drawn as a single dashed red box straddling both machines, half labelled ACME's half and half VENDOR's half, with a red cross at the boundary: one channel with two owners, and no shard can own it. Its consequence: pick one shard and the other workspace is permanently cross-shard for its own conversation; pick both and you dual-write; either way, workarounds and performance penalties. Right, AFTER, shard key equals channel_id: the same two workspaces both point at one place, and #deal-room channel C9 sits wholly inside shard 12 as one row set with one home, marked with a green tick because nothing crosses the boundary, while ACME's other channel #acme-general C77 sits on shard 40. Its consequence: one entity, one home; both workspaces reference it by id, neither owns its storage, and a hot tenant's channels now spread across the fleet instead of pinning one host. The bill is that section 6's free single-shard joins are gone.
Why the shard key change is the actual unlock

The Numbers

Duration2017 → December 2020, ~3 years; 99% of MySQL traffic migrated
Throughput2.3M QPS at peak — ~2M reads, ~300K writes
Latencymedian 2 ms, p99 11 ms
TopologyMultiple clusters, dozens of keyspaces, several geographic regions

The proof point is March 2020. COVID drove 50% query growth in a single week. Using Vitess resharding, Slack split their busiest keyspace horizontally with no downtime — an operation they describe as "impossible with [the] legacy architecture." And Vitess is credited with enabling not just capacity but Slack Connect and international data residency, both of which are the workspace sharding part’s constraints expressed as product features.

  • Guarantees: Load can be redistributed without application changes — a hot shard is now split online rather than escalated — and an entity shared by two tenants has a real home instead of a workaround.
  • Does not guarantee: That the workspace sharding part’s free single-shard joins survive. Once messages shard by channel and other data by workspace, queries spanning both are genuinely distributed — and the operational simplicity of "all of a customer lives here" is gone, which is a real loss for export, deletion, and residency.