MongoDB & MongooseInterview preparation
Intermediate·Concept·2 min read

Replication vs sharding: what is the difference?

Practice this question

Definition:

Replication keeps copies of data so a system can recover from node failure, while sharding distributes different subsets of data across nodes. Replica sets improve redundancy; sharding spreads storage and workload. A sharded deployment can also replicate each shard, so these techniques are complementary.

Key points:

  • Replication keeps copies for availability and failover.

  • Sharding splits data across servers to spread storage and traffic.

  • A poor shard key can send most writes to one shard or require queries across all shards.

  • A shard key that increases monotonically can concentrate new writes, while queries without useful shard-key filters may contact many shards.

Interview point:

  • Describe distribution, access patterns and hot spots before saying a system can simply “add shards.”
Adapted from 04_MONGODB_MONGOOSE.md · “Replication vs sharding: what is the difference?”. Code examples are study fragments. Difficulty and core labels are editorial estimates; version-specific behavior should be checked against your project.