Replication vs Sharding
Replication copies data for high availability and read scaling; sharding splits data across nodes for write scaling. They solve different problems and are often combined.
By Ratish Jain · Updated
The Decision
These are not really rivals — they scale different dimensions. Replication keeps full copies of the same dataset on multiple nodes. It buys high availability (a replica takes over on failure) and read scaling (spread reads across copies), but every node still holds all the data and all writes ultimately go through the primary.
Sharding splits the dataset horizontally by a key across nodes, so each shard holds only a slice. This scales writes and storage beyond one machine, but adds routing, rebalancing and cross-shard query pain.
So it depends on your bottleneck: reads and availability point to replication, write/storage volume points to sharding — and large systems usually do both, replicating each shard.
Side by Side
| Replication | Sharding | |
|---|---|---|
| What it does | Copies full dataset | Splits dataset by key |
| Primary goal | HA + read scaling | Write + storage scaling |
| Data per node | Entire dataset | One partition only |
| Write scaling | Limited by primary | Scales across shards |
| Failure impact | Replica takes over | One shard's data affected |
| Complexity | Lag, failover, consistency | Routing, rebalancing, cross-shard joins |
| Query reach | Any node has all data | Cross-shard queries costly |
Sharding Strengths & Weaknesses
- Scales writes and total storage beyond a single machine
- Failures are isolated to one shard's key range
- Smaller per-node datasets keep indexes and working sets fast
- Cross-shard joins, aggregations and transactions are hard
- Choosing a shard key wrong causes hotspots and skew
- Rebalancing and resharding are operationally painful
Decision Guide
Reach for replication first when reads dominate or you need high availability and failover — it is simpler and often enough. Add sharding only when a single primary can no longer absorb the write throughput or the dataset outgrows one machine. Large-scale systems combine them: shard the data, then replicate each shard for redundancy and read fan-out.
Real-World Examples
- MySQL read replicas
- Classic replication for read-heavy web apps
- MongoDB
- Sharded clusters where each shard is a replica set
- Cassandra
- Partitions by hash and replicates via replication factor
- Sharded PostgreSQL to scale writes across many nodes
Interview Questions
In leader-based replication all writes funnel through the primary and are then copied to replicas, so replicas add read capacity but the write ceiling stays fixed at one node — that requires sharding.
The key determines data and load distribution; a poor choice (e.g. sharding by a low-cardinality or monotonically increasing field) creates hotspots where one shard gets most traffic, defeating the purpose. Consistent hashing helps spread and rebalance keys.
- →Replication = full copies; scales reads and gives HA.
- →Sharding = split by key; scales writes and storage.
- →Replication's write ceiling stays at the primary.
- →Sharding adds routing, hotspots, and cross-shard query cost.
- →Big systems shard first, then replicate each shard.
Related
Everything on Archprimer is connected — follow the graph.