Design a horizontally scalable database that shards data across many nodes and replicates for durability. Clients must route to the right shard, survive failures, and optionally tune consistency per request.
Functional requirements
- Hash or range sharding with deterministic key routing
- Read/write APIs with tunable consistency (strong vs bounded staleness)
- Automatic failover and replica promotion when nodes fail
- Online rebalancing when shards are added or split
- Metadata service for topology, schemas, and epoch/version of the shard map
Non-functional requirements
- Linear scale-out of write throughput with shard count
- Durable commits via replicated write-ahead logs
- Bounded tail latency under node loss and partial partitions
- Observable replication lag, conflicts, and hotspot metrics