02 / 11

What is Replica Set?

A replica set in MongoDB is a group of mongod processes that maintain the same data set.

  1. 1

    Each replica set node must belong to one, and only one, replica set. Replica set nodes cannot belong to more than one replica set.

  2. 2

    A replica set contains several data bearing nodes and optionally one arbiter node. Of the data bearing nodes, one and only one member is deemed the primary node, while the other nodes are deemed secondary nodes.

Difficulty: 5/10
Topics: replication, high availability, failover

Scenario Questions

0-2 years experience
  1. 1

    If you need to add a secondary node to an existing replica set to improve read capacity, what steps would you take?

  2. 2

    What happens to client reads when the primary of a replica set goes down and you have readPreference set to 'primaryPreferred'?

  3. 3

    How would you configure a replica set with three members to ensure automatic failover?

2-5 years experience
  1. 1

    We observed occasional stale reads after a primary stepdown. Can you walk me through why that might happen and how you'd mitigate it?

  2. 2

    During a deployment, writes started failing with a 'not master' error. How would you troubleshoot the replica set state?

  3. 3

    Explain the trade‑offs between using an even number of voting members versus an odd number in a replica set.

5-8 years experience
  1. 1

    Design a strategy to scale read traffic across a geographically distributed replica set while keeping write latency low.

  2. 2

    How would you handle a scenario where a secondary falls behind the oplog and cannot catch up, affecting your backup strategy?

  3. 3

    Discuss the impact of write concern and read concern settings on data consistency and availability in a replica set under network partitions.

8+ years experience
  1. 1

    We need to migrate a legacy monolithic application using a single MongoDB instance to a sharded cluster with replica sets. What architectural considerations around replica set configuration would you prioritize?

  2. 2

    How would you design a cross‑region disaster recovery plan using replica sets, considering latency, failover time, and operational overhead?

  3. 3

    When multiple teams share the same replica set, what governance and configuration policies would you put in place to avoid conflicts and ensure stability?

Follow-up Questions

  • Can you walk me through the election process when the primary steps down?
  • What metrics would you monitor to detect replica set health issues early?
  • How would your solution differ if you had an even number of voting members?