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
Create a database
Query with a stale route
A storage node dies
Balance a hot node
A worker dies mid-move
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
The numbers, at a glance
≈ 50 writes/s25,000 heartbeats/s
27 s500 nodes
77 s2K nodes
11 min20K nodes
28 min50K nodes
6 sPer shard
310/s used8,000 writes/s
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.
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.
2.5M shard leaders
Renew lease every 3 s
Store at 100× its limit
+ Proven, prevents two leaders.− 833,000 lease renewals a second.
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.
OperatorsRouters
Coordinator
Metadata DBStorage nodes
OperatorsRouters
Control APIWorkflow workersHealth monitors
Store, 5 votersRaft per shard
OperatorsRouters
Watch relaysPlacement
Control APIWorkflow workersHealth monitors
Store, 5 votersStorage nodesBackups
OperatorsRouters
Control APICell directory
Cell × 5
Store, relays, monitors, workflows, placement per cell
Was this walkthrough useful?Your vote tells us what to improve next.