Replication
Copying data across nodes for durability, availability, and read scaling. Can be synchronous (strong, slow) or asynchronous (fast, lossy on failover). Single-leader, multi-leader, and leaderless are the main topologies.
- HA, durability, read scaling, and geo-local reads.
- Any data you can't afford to lose.
- When a single copy with backups suffices.
- Write-heavy workloads where replicas only add cost.
Definition
Replication keeps copies of data on multiple nodes. A primary accepts writes and ships them to replicas (single-leader); multi-leader allows writes at several; leaderless (Dynamo-style) writes to a quorum. Synchronous vs async sets the durability/latency tradeoff.
Why it exists
One copy means one failure loses everything. Replication adds redundancy (durability/availability) and read capacity, and geographic replicas cut latency. It's the foundation of HA.
How it works
Writes go to the leader, which replicates via a log (WAL/binlog). Sync replication waits for replicas before ack (strong, slower); async acks immediately (fast, may lose recent writes on failover). Replicas serve reads (eventually consistent) and can promote on leader failure.
Scaling limits
Sync replication adds commit latency; async risks data loss on failover. Replication lag causes stale reads. Multi-leader needs conflict resolution. More replicas = more write amplification.
Cost shape
Storage + network per replica. Blow-ups: over-replication, cross-region replication egress, and lag causing read staleness.
Alternatives
- Erasure coding — Less storage overhead for durability, but no read scaling or failover.
- Backups only — Cheaper but slow recovery and no live redundancy.
Failure modes
- Replication lag causing stale reads.
- Split-brain on failover.
- Data loss with async replication.
Related terms
WAL (write-ahead log), Quorum, Raft, Eventual consistency, Snapshot