Partitioning and replication
Partition to scale beyond one machine; replicate to survive one. Each brings its own failure mode.
What are you trying to do?
Spread data and work across machines without losing it or serializing on it.
Why are you doing it?
One machine caps throughput and storage and is a single point of failure. Partitioning (sharding) splits data by key so work scales out, but a hot key or a bad partition function concentrates load on one node (skew). Replication keeps copies for availability and read scaling, but copies must agree. Single-leader replication is simple but makes the leader a bottleneck. Multi-leader and leaderless replication accept writes anywhere at the cost of conflict resolution.
Write path (single-leader shard)
Key
The record key from the client
Partition function
Maps the key to one shard
Shard leader
Accepts the write for that shard
Replicate
Send the write to the followers
Acknowledge
Reply once the replication policy is met
Choosing the partition function
Dominant access pattern
Point lookups or ordered scans?
Pick the function
Hash: even spread, key order lost. Range: ordered scans, hot ranges risk skew
Rebalance
Consistent hashing or many fixed partitions keep data movement small
The partition function decides which shard owns a key; replication decides how many copies must agree before the write is acknowledged.
Designing Data-Intensive Applications (2nd ed.)Think Distributed Systems
How are you going to do it?
- Partition by a high-cardinality key that matches the dominant access pattern: hash partitioning for even spread, range partitioning for ordered scans.
- Choose a replication scheme by write locality and conflict tolerance; use quorums (W + R > N) when leaderless.
- Treat rebalancing as a design concern — consistent hashing or many fixed partitions per node keeps data movement small when nodes join.