← MongoDB learning pathMongoDB · Module 9 of 10
Replication and sharding
Make MongoDB highly available and scalable.
📖 Key ideas
- A replica set has one primary and secondaries copying its data.
- If the primary fails, an election picks a new one.
- Sharding splits data across machines by a shard key.
- A good shard key spreads writes evenly.
- Atlas manages replication and sharding for you.
💡 Real-life example: Replication is keeping photocopies in different branches; sharding is splitting the files across many cabinets.
Replica setGroup of servers with copies of data
PrimaryNode accepting writes
ShardingSplitting data across servers
Shard keyField deciding data placement