Sample questions
Mongodb Replication ShardingDifficulty 1
In a MongoDB replica set, what role does the primary node play?
- aIt accepts the replica set's client writes✓
- bIt only stores backup copies of data and never answers client requests
- cIt coordinates elections but forwards all reads and writes to secondaries
- dIt is elected once and never changes for the lifetime of the replica set
Explanation:A replica set has exactly one primary at a time, and only the primary accepts writes; secondaries replicate the primary's oplog and, by default, don't accept writes. The primary can change over time via elections (d is wrong), and it does answer client requests directly rather than just coordinating (b, c are wrong).
Mongodb Replication ShardingDifficulty 1
What is a secondary member's default behavior in a MongoDB replica set?
- aIt accepts writes directly from clients and forwards them to the primary
- bIt applies the oplog and can serve opt-in reads✓
- cIt permanently stores a read-only snapshot taken once at replica set creation
- dIt becomes primary automatically as soon as it finishes its initial sync
Explanation:Secondaries continuously apply the primary's oplog to stay in sync and, by default, reject client reads unless the driver's read preference explicitly allows reading from a secondary. They don't accept writes (a), don't freeze at one snapshot (c), and initial sync completion alone doesn't make a node primary — that requires an election (d).
Mongodb Replication ShardingDifficulty 1
What is the purpose of an arbiter in a MongoDB replica set?
- aIt holds a full read-only replica of the data for reporting queries
- bIt becomes primary if the current primary and all secondaries fail
- cIt votes in elections to help establish a majority but stores no data✓
- dIt compresses the oplog so secondaries can catch up faster
Explanation:An arbiter is a lightweight member that participates only in voting during elections, adding a vote to help reach majority without holding a copy of the data set. Because it has no data, it can never become primary (b) or serve reads (a), and it plays no role in oplog compression (d).
Mongodb Replication ShardingDifficulty 2
What is the oplog in a MongoDB replica set?
- aA diagnostic log file that records slow queries for later performance analysis
- bAn index MongoDB builds automatically on every collection's _id field
- cA user-facing audit trail of who read which documents and when
- dThe capped collection that records replicated operations✓
Explanation:The oplog (operations log) is a special capped collection on the primary that records every write in order; secondaries tail it and reapply the operations to replicate data. It has nothing to do with slow-query logging (a), the automatic _id index (b), or a read-audit trail (c).
Mongodb Replication ShardingDifficulty 2
With the default read preference mode primary, where does a driver send read operations?
- aOnly to the current primary✓
- bTo whichever healthy member responds fastest, regardless of primary or secondary role
- cAlways to a secondary, to keep load off the primary
- dRound-robin across primary and secondaries in equal proportion
Explanation:primary is the default read preference: all reads target the primary, and if the replica set currently has no primary (e.g. during an election), reads with this mode fail rather than falling back to a secondary. Modes like secondaryPreferred or nearest are what change that behavior (b, c, d).
Mongodb Replication ShardingDifficulty 2
A write is issued with w: 1. What acknowledgement does the client wait for?
- aAcknowledgement from a majority of voting members before the write is considered successful
- bAcknowledgement from the primary alone✓
- cAcknowledgement from every secondary in the replica set, one by one
- dNo acknowledgement at all; the driver assumes success once the socket write completes
Explanation:w: 1 means the primary alone must acknowledge the write; the client doesn't wait for replication to any secondary. w: "majority" is what waits for acknowledgement from a majority of voting members (a); waiting for every secondary isn't what w: 1 does (c), and it's still a real acknowledgement, not a fire-and-forget write (d).