Replication
- Leader–follower: writes to leader, reads from followers. Async = fast but replication lag (read-your-writes issues; route a user's reads to the leader for a few seconds after they write). Sync = durable but slower.
- Multi-leader: writes in several regions; must resolve conflicts (last-write-wins, CRDTs, app logic).
- Leaderless (Dynamo/Cassandra): write to W of N replicas, read from R; R + W > N gives overlap → read sees latest write. Repair with read-repair and anti-entropy (Merkle trees).
N=3, W=2, R=2: write -> [A ✓] [B ✓] [C ✗]
read <- [B] [C] B has the new version -> overlap guaranteed
Failover: detect leader death (heartbeats), elect a new leader (Raft/Paxos/ZooKeeper), fence the old one to avoid split brain.