MongoDB & NoSQL (50 Qs)•Part 3: Advanced Internals, Scale & Production Patterns (Senior / Lead)
Replica Set Architecture and Oplog Internals.
senior LevelSystem Design
In Simple Words: A MongoDB Replica Set consists of a Primary node and multiple Secondary nodes:
- Oplog (Operations Log): A capped collection on the Primary storing an idempotent sequence of all write operations. Secondaries asynchronously tail the Oplog to replicate data.
- Automated Failover: If the Primary stops sending heartbeats for 10 seconds, Secondaries hold an election using Raft consensus and elect the Secondary with the most up-to-date Oplog as new Primary within seconds.