What is database replication and what are the common replication topologies?
Take a moment.
Say your answer out loud or write it down first — retrieval is what makes it stick. Reveal when you're ready.
Short answer
Replication copies data across multiple servers so reads scale and the system survives failures. Topologies: single-leader (one primary handles writes, replicas serve reads — simple, but the leader is a bottleneck and SPOF), multi-leader (multiple nodes accept writes — good for multi-region but conflicts arise), and leaderless (any node accepts reads/writes with quorum consistency — highest availability but complex). Choose based on whether you prioritize write simplicity, multi-region writes, or maximum availability.
Detailed explanation
Replication keeps copies of data on separate machines. Single-leader (primary-replica): one node is the leader that processes all writes and ships a write-ahead log or change stream to follower replicas. Replicas serve read queries, scaling read throughput. Pros: simple, no write conflicts. Cons: leader is a write bottleneck and single point of failure (failover promotes a replica, with potential brief downtime or data loss); replication can be synchronous (strong consistency, higher write latency) or asynchronous (fast writes, but replicas lag and may lose recent writes on failover). Multi-leader: multiple nodes accept writes and replicate to each other. Useful for multi-region deployments (each region has a local leader for low-latency writes) but introduces write-write conflicts that need resolution (last-write-wins, CRDTs, or application-level merge). Leaderless (Dynamo-style): any node can accept reads and writes; the client coordinates with multiple nodes and uses quorum (W + R > N) to guarantee consistency. Highest availability — no single point of failure — but requires conflict resolution (vector clocks, read repair) and tunable consistency.
Example
Single-leader (typical web app):
- Primary PostgreSQL in us-east-1 handles all writes.
- Two read replicas serve dashboard queries.
- Synchronous replication to one replica for zero data loss on failover.
Leaderless (DynamoDB-style):
- N=3 replicas, W=2 write quorum, R=2 read quorum.
- Any node accepts writes; client reads from 2 and takes the latest.Interview tip
Name all three topologies and the trade-off each optimizes. Then distinguish synchronous versus asynchronous replication within single-leader — that detail shows operational depth.
Common mistakes
- Only describing single-leader and missing multi-leader and leaderless.
- Not distinguishing synchronous from asynchronous replication.
- Forgetting that single-leader replication does not scale writes.