Skip to main content

Replication

Replication maintains synchronized data copies across servers for availability, durability, and read scalability.

Replication is the maintenance of multiple copies of the same data across different database servers. By keeping synchronized replicas, a system can survive node failures, serve reads from nearby copies, and distribute load.

How It Works

Replication topologies include:

  • Primary-replica (leader-follower): One primary accepts writes and streams changes to read-only replicas. Simple and common, but the primary is a write bottleneck and a failover point.
  • Multi-primary (multi-leader): Several nodes accept writes, requiring conflict resolution.
  • Quorum-based: Writes and reads succeed when a majority of replicas agree, as in Cassandra or DynamoDB.

Replication can be synchronous (a write waits for replicas to acknowledge, ensuring no data loss but adding latency) or asynchronous (the primary commits immediately and replicas catch up, risking small data loss on failure). The delay between primary and replica is called replication lag.

Under the hood, engines ship a write-ahead log or binary log, or use change data capture, to propagate changes.

Why It Matters

Replication provides high availability through failover, durability through redundant copies, lower read latency through geographic replicas, and read scalability by spreading queries. It is a building block of nearly every production database deployment.

The trade-offs are replication lag (causing stale reads) and the consistency choices the CAP theorem forces during partitions.

Related Terms

Replication is often combined with sharding, governed by the CAP theorem, and frequently implemented using change data capture.