Question #23 of 60•Databases•Hard• ~3 min read

How do Master-Replica, Multi-Master, and Leaderless Database Replication operate?

Executive Takeaway

Examine database replication topology trade-offs, read scaling, replication lag, and quorum consistency formulas.

Architectural Breakdown & AnalysisFAANG Aligned

Database replication distributes copies of data across nodes for high availability and read scaling.

1. Master-Replica (Leader-Follower)

  • Writes execute exclusively on the Master node.
  • Master streams write logs to Replica nodes for read processing.
  • Trade-off: Simple, scales reads easily, but Master is a write SPOF and replicas face replication lag.

2. Multi-Master (Leader-Leader)

  • Multiple nodes accept writes concurrently.
  • Trade-off: High write availability across regions, but requires complex write conflict resolution.

3. Leaderless (Quorum-Based: Cassandra)

  • Any node accepts writes and reads. Quorum consensus determines success.
  • Quorum Formula: $R + W > N$ (where $R$ = read quorum, $W$ = write quorum, $N$ = total replicas). Guarantees strongly consistent reads.
TIP — Quorum Selection

For $N=3$, configure $W=2$ and $R=2$ to tolerate 1 node crash while guaranteeing up-to-date reads.

Key Architectural Comparison

Replication TopologyWrite DestinationRead ScalabilityConflict ResolutionFailover Complexity
Master-ReplicaSingle primary master node.High (multiple read replicas).None needed (single write stream).Moderate (Sentinel / Raft leader promotion).
Multi-MasterAny master in the cluster.High.Complex (Last-Write-Wins or CRDTs).Low (other masters already active).
Leaderless (Dynamo)Quorum write across $W$ nodes.High ($R$ nodes read).Read repair & anti-entropy Merkle trees.Zero (no masters to elect).
Previous QuestionHow does the Circuit Breaker Pattern prevent cascading failures in microservices?Next Question How do CDNs leverage Edge Caching, Anycast Routing, and Dynamic Site Acceleration?

Continue Learning on Being SDE

Explore deep-dive system architecture modules, low-level object-oriented designs, and interview cheat sheets.