Back to sketch

SYSTEM DESIGN SKETCHBOOK / PRACTICE SHEET / NO. 34

Design the control plane for a managed database service

Expert · 55 min · Distributed infrastructure

Customers of a managed database service click "create cluster", pick a size and a region, and expect a working primary with replicas in minutes. After that they expect the service to replace failed machines, fail over automatically, apply patches, and roll out configuration changes without them noticing. You are designing the system that does all of that, not the database engine itself.

Requirements

  • Create, resize, and delete database clusters (one primary and two replicas each) through an API.
  • Place replicas on hosts with enough capacity, in three different availability zones.
  • Detect a failed primary and promote a replica automatically.
  • Roll out engine versions and configuration changes across the fleet safely, and apply customer schema changes to a cluster.

Constraints and assumptions

  • 20,000 customer clusters on 15,000 hosts in 3 regions, each region with 3 availability zones.
  • A new cluster should be serving within 10 minutes; API traffic is about 50 requests per second.
  • A failed primary must be replaced by a promoted replica within 30 seconds, and there must never be two writable primaries for one cluster.
  • Writes acknowledged to customers must survive the loss of a single host (replication is semi-synchronous to at least one replica).
  • If the control plane is down, existing databases must keep serving reads and writes.
  • Average cluster holds 200 GB of data.

Out of scope for the first sketch

The storage engine and query processing · Billing and metering · Cross-region disaster recovery

Draw your design

Rough math and notes

Done on paper? Compare with the worked approaches