/ System Design / Database Replication ← All Designs
🔄

Database Replication

Keep multiple copies of your data in sync for high availability and read scaling

High Availability Read Scaling Disaster Recovery MySQL / PostgreSQL
Replication Topology ● Stopped
💻
Writer
📱
Reader
PRIMARY
🗄️
Writes: 0
Reads: 0
binlog pos: 000000
↓ Async Replication ↓
BINLOG STREAM
0
Total Writes
0
Reads (Primary)
0
Reads (Replicas)
0ms
Max Lag
Availability & Durability
99.9%
Estimated Availability
High
Durability
~1ms
Write Latency

Key Concepts

🎯 When to Use
  • Read-heavy workloads (scale reads)
  • Need geographic redundancy
  • Disaster recovery requirements
  • Zero-downtime maintenance windows
⚖️ Trade-offs
  • Async: fast writes, potential data loss
  • Sync: zero loss, slower writes
  • Replication lag causes stale reads
  • Complex failover logic needed
🎓 Interview Tips
  • RPO vs RTO — data loss vs recovery time
  • Split-brain problem in failover
  • Read-your-writes consistency issue
  • MySQL binlog, Postgres WAL streaming