Databases / MongoDB
Replication and Transactions
Replica sets, failover, and multi-document transactions.
Replica sets in MongoDB
A replica set copies data across multiple mongod processes for redundancy and automatic failover. This chapter explains primary and secondary roles, elections, a local three-node Docker Compose layout, read preferences, write concern, and replica set connection strings.
Transactions in MongoDB
Single-document updates are atomic; multi-document business rules need sessions and transactions on a replica set. This chapter covers withTransaction, read and write concern inside transactions, limits, and when schema design removes the need for cross-collection locks.