Skip to content
SD-34 · Back to the write-up

Design a Database Control Plane

Keep the shard map in a small consensus store, push changes to routers, let shards elect their own leaders, and run every long change as a durable workflow inside a cell.

Follow a request

Callers
Global + routing
Cell control plane
Data plane
OperatorsAPI and automation
ApplicationsCustomer queries
Control APIStateless
Cell directoryDatabase → cell
Query routersCached map
Workflow workersDurable steps
PlacementPlans moves
Metadata store5 voters, Raft
Watch relaysPush deltas
Health monitorsHeartbeats
Storage nodesRaft per shard
Backup storageSnapshots + log
1nodes → health · heartbeats stopNode 7 loses power. Within about 6 s, each of its ≈ 50 led shards elects a new leader among the other 2 replicas, on their own.1 / 6

The numbers, at a glance

Heartbeats that become writesAbout 1 in 500; each dot is 5 heartbeats
≈ 50 writes/s25,000 heartbeats/s
Time to recover from a zone lossCentral coordinator at 500 leaders/s vs elections in each shard
The store is barely usedWrites per cell against what consensus commits
Cells keep it this way: a bigger fleet adds cells, not writes.

A replica move, in order

Each worker step is saved to the store before the next, so any worker can resume.

Placement
Metadata store
Workflow worker
Target node
Source node
Watch relays
1 create move task
2 claim with lease
3 add learner, gen 9
4 snapshot + log
5 caught up
6 save step 2
7 promote target, remove self
8 gen 10, task done
9 change stream
RequestResponseAsync, does not block

Who decides failover

The decision this question is really about.

Central coordinator
Breaks static stability
Node 7 dies
Coordinator notices500 leaders/s
Control plane down → no failover
+ One place decides.− Failover needs the control plane; 28 minutes for a zone.
Leases in the store
Too many writes
2.5M shard leaders
Renew lease every 3 s
Store at 100× its limit
+ Proven, prevents two leaders.− 833,000 lease renewals a second.
Consensus in each shard
Our pick
Node 7 dies
Replicas voteNew leader in ≈ 6 s
Control plane only replaces the copy
+ Works with the control plane down.− 150 small groups per node to batch.

How it grows

Add a box only when a number forces you to. Highlighted boxes are new at each stage.

Stage 1 · ≈ 500 nodesMake it work
OperatorsRouters
Coordinator
Metadata DBStorage nodes
One coordinator, one SQL database, routers that poll.
Stage 2 · ≈ 2,000 nodesMake the brain survive
OperatorsRouters
Control APIWorkflow workersHealth monitors
Store, 5 votersRaft per shard
Consensus store, shards elect leaders, monitors, workflows.
Stage 3 · ≈ 20,000 nodesPush the map
OperatorsRouters
Watch relaysPlacement
Control APIWorkflow workersHealth monitors
Store, 5 votersStorage nodesBackups
Relays push deltas, placement balances, backups stream out.
Stage 4 · ≈ 50,000 nodesSplit into cells
OperatorsRouters
Control APICell directory
Cell × 5
Store, relays, monitors, workflows, placement per cell
Cells of 10,000 nodes, a directory to find them.
Was this walkthrough useful?Your vote tells us what to improve next.