A replica set is a group of MongoDB servers that maintain the same data — providing high availability (automatic failover) and redundancy. One node is the primary (handles writes), others are secondaries (replicate the primary's data and can serve reads). It's MongoDB's standard mechanism for reliability.
The replica set structure
PRIMARY (1) → receives all WRITES; replicates changes to secondaries
SECONDARIES (2+) → copy the primary's data (via the oplog); can serve READS
ARBITER (optional) → votes in elections but holds no data (for odd vote counts)
Write → Primary → replicated to Secondaries (via the operations log "oplog")
