Replication copies data for availability and read scaling; sharding splits data across nodes for write/storage scaling. They solve different problems and are often combined.
Key ideas
- Replication: leader/follower copies — survive node loss, scale reads, risk replication lag.
- Sharding: partition by a key (hash or range) — scale writes/storage, risk hot shards.
- Choose a shard key with high cardinality and even access to avoid hotspots.
Compare
| Technique | Primarily scales |
|---|---|
| Replication | Reads + availability |
| Sharding | Writes + storage |