← All tutorials

GoCareerGo Tutorials

MongoDB Tutorial

Documents, collections, CRUD, aggregation, Atlas and driver connectivity.

Replication in MongoDB

A replica set is a group of MongoDB servers holding the same data — one primary handles writes, secondaries replicate it for redundancy and read scaling.

  • Primary — accepts all writes, replicates changes via the oplog
  • Secondary — replicates the primary's data, can serve reads
  • If the primary fails, the replica set automatically elects a new primary