vishal patel
UnderstoodIntermediateUpdated 2026-09-23

Replication

Keep copies of data on multiple nodes for availability, durability and read scaling — single-leader, multi-leader and leaderless, sync vs async.

high-availabilityfailoverreplica-setsdurability

Three topologies

diagram
Single-leaderMulti-leaderLeaderless
WritesOne nodeSeveralAny quorum
ConflictsNoneMust resolve (LWW, CRDTs)Must resolve (read repair)
UseDefaultMulti-region writes, offline clientsVery high write availability

Sync vs async

  • Synchronous: the write is acknowledged after replicas confirm. Durable, but slower, and blocks if a replica is down.
  • Asynchronous: fast, but failover can lose acknowledged writes.
  • Quorum / majority: MongoDB w: "majority" means the write survives any single-node failure. The usual production choice.

Failure scenarios to design for

  • Replication lag leads to stale reads from secondaries (see read-your-writes).
  • Failover picks a new leader; clients must retry writes idempotently.
  • Split brain: two nodes think they're leader. Prevent it with majority elections and fencing tokens.
  • Leaderless quorums: with W + R > N, reads overlap the latest write.

Cheatsheet

The whole topic on one page. Click to open full screen.

Sources & further learning

Videos, courses, docs and books I recommend for this topic.

Related topics