Why it matters

Every serious production DB uses replication. Getting the setup right shapes availability, latency, and consistency. Understanding options is core DB ops.

Advertisement

The architecture

Streaming replication: primary sends WAL/binlog stream to replicas. Replica applies to catch up.

Logical replication: primary sends row-level changes. Enables cross-version and selective replication.

Replication typesStreaming (WAL)physical, all-or-nothingLogical (rows)flexible, cross-versionSync vs asyncconsistency vs latencyAsync replicas can lag; sync replicas trade write latency for consistency
Replication choices.
Advertisement

How it works end to end

Sync replication: primary waits for replica ack before commit. Strong consistency, higher write latency.

Async replication: primary commits, replica catches up. Lower latency, replica may lag.

Failover: replica promoted when primary fails. Manual or automatic. Auto-failover risks split brain.

Read replicas: applications route reads to replicas for scale. Watch for stale-read issues.