Lesson 20 / 22
Replication & Replica Sets
Keep copies of data for high availability and redundancy.
What is a replica set?
A replica set is a group of mongod servers holding the same data — one primary takes writes, and secondaries copy them.
Why replicate?
It gives high availability (a secondary is promoted automatically if the primary fails), redundancy, and optionally lets reads scale across secondaries.
Writes go to the primary
By default all writes target the primary node — reading from secondaries can return slightly stale data due to replication lag.