Replication for MongoDBs
MongoDB replication keeps copies of data on several servers using a replica set: one primary accepts writes and secondaries copy its oplog. If the primary fails, an election chooses a new one. This unit in the Operations stage also covers write concern, read preference and backups with mongodump or snapshots.
Stage: Operations · Part of the MongoDB roadmap · Last reviewed 19 November 2026
What to learn in Replication
- Describe the roles of primary, secondary and arbiter in a replica set
- Explain how the oplog lets secondaries stay in sync
- Set write concern majority to protect writes during failover
- Choose a read preference and understand the stale-read risk
- Take and restore a backup using mongodump and mongorestore
Replication interview questions
What happens when the primary in a MongoDB replica set fails?
The remaining members hold an election, and one with a majority of votes becomes the new primary, usually within seconds. Drivers detect this and retry eligible operations. A set needs a majority of voting members available to elect, which is why odd counts are used.
What does write concern majority mean?
It makes the server acknowledge a write only after a majority of replica set members have applied it. Such data survives a failover, because a majority-acknowledged write is on the node that wins the next election. The cost is slightly higher latency.
Where Replication fits in the MongoDB roadmap
Replication belongs to the Operations stage (advanced level), which takes about 12 hours. Reliability and scale.
Other units in this stage
Back to the full MongoDB roadmap