Design a Database Control Plane
Design the control plane of a managed, distributed database. The data plane is a fleet of storage nodes that hold the data, split into shards by key range, with 3 replicas of each shard in 3 zones. The control plane is everything around it: it knows which node holds which shard, notices when a node dies, moves replicas to balance load, splits shards that grow too big, creates and deletes customer databases, runs backups and rolls out upgrades. Applications never talk to it directly; they talk to query routers that need its shard map.
The fleet has 50,000 storage nodes holding 2.5 million shards and 7.5 million replicas, serving about 100 million queries a second. The control plane takes few requests, but it is the source of truth for the whole fleet: a wrong shard map means two leaders for one shard and lost writes, a slow failure detector means minutes of downtime, and a control plane outage must never take queries down with it. The hard parts are consistency of a small amount of very important data, reacting to failures fast without reacting to false alarms, and keeping one bug or one bad deploy from touching the whole fleet.
Good questions to ask first
Decide what you would assume for each before you look at ours.
- 1Is the control plane on the query path?
- 2How big is the fleet?
- 3Who elects the leader of a shard?
- 4How fast must we recover from a node or zone loss?
- 5What does a customer see?
- 6How often does the map change?
- 7Do we run schema changes and upgrades?
- 8Multi-region?
How to spend the 45 minutes
- 5minPart 1: Requirements, and what the control plane is not
- 5minPart 2: Estimates: heartbeats, changes, map size
- 5minPart 3: API and data model
- 15minPart 4: Architecture, stage by stage
- 15minPart 5: Failover, workflows, cells and trade-offs