← MongoDB learning path
MongoDB · Module 9 of 10

Replication and sharding

Make MongoDB highly available and scalable.

📖 Key ideas

  1. A replica set has one primary and secondaries copying its data.
  2. If the primary fails, an election picks a new one.
  3. Sharding splits data across machines by a shard key.
  4. A good shard key spreads writes evenly.
  5. 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