techdiagrams.net
← All templates

Sharded SQL (Vitess-style)

A query router fans SQL across range shards via a topology service — with scatter-gather reads, 2PC for cross-shard writes, and a live range split in progress.

Open in editor — free, no login Download JSON
SHARD FLEET — RANGES OF THE KEYSPACESELECT / INSERTresolve rangesscatterscatter → gathercross-shard write · 2PCrange split · filtered backfillApplicationplain SQL — no shard awarenessQuery router (vtgate)plan · route · gatherTopology serviceshard map · consistent coreShard [-80)primary + replicasShard [80-c0)primary + replicasShard [c0-)HOT · splitting…Shard [c0-e0) — newbackfillingdesign rule: model queries so 95%+ hit ONEshard (shard by tenant/user). scatter-gatherand 2PC exist — as exceptions, priced in.

What this design does

How YouTube scaled MySQL and how PlanetScale works today: applications keep speaking plain SQL to a router, which consults the shard map, pushes single-shard queries to one primary, and scatter-gathers the rest. The diagram includes the operationally interesting moment most drawings skip — a shard mid-split, backfilling its new neighbor before the cutover.

The patterns it composes

Import it, attach your own numbers, and verify the design against failures — or read the engineering notes.