Dashboard
Courses
Problems
Badges
Theme
Sign inStart free
Courses/Distributed Architecture
Lesson 8 of 24

Replication topologies

Leader/follower, multi-leader and leaderless replication: who accepts writes and what that costs.

20 min read

Single leader

One node accepts writes and streams its change log to followers, which serve reads. This is PostgreSQL, MySQL, MongoDB replica sets and most managed databases. It is simple to reason about: there is one order of writes, so no write conflicts. Write throughput is capped by the leader, and failover takes time: detecting a dead leader with heartbeats takes 10 to 30 seconds in many setups, then a follower is promoted. With asynchronous replication, writes acknowledged in the last moments before the crash can be lost.

Replication lag is a feature you must design around

Followers typically trail the leader by milliseconds, but under load or after a network blip lag can reach seconds or minutes. A user who updates their profile and immediately reloads from a lagging follower sees the old value. Mitigations include reading your own recent writes from the leader, pinning a user to one follower, or tracking the log position of the user's last write and waiting until the follower has caught up.

  • Semi-synchronous: wait for one follower to confirm, others async
  • Monitor lag in seconds and in bytes, and alert on both
  • Never route a read that must be fresh, such as a balance check before payment, to a follower

Multi-leader

Several nodes, usually one per region, accept writes and replicate to each other asynchronously. Users write locally with low latency, and each region survives the others going dark. The price is write conflicts: two regions can change the same record concurrently, and the system must resolve them, which is the subject of a later lesson. Multi-leader is also how offline-capable clients behave: each device is a leader that syncs later. Avoid multi-leader inside a single region: the latency it saves there is small and the conflicts are just as real.

Leaderless

In Dynamo-style systems (Cassandra, Riak, DynamoDB internally), the client or a coordinator sends each write to all N replicas and waits for W acknowledgements, and reads from R replicas, taking the newest version. There is no failover because there is no leader; a slow or dead replica is simply outvoted. Stale replicas are repaired by read repair and by background anti-entropy that compares Merkle trees of key ranges. Concurrent writes to the same key are possible, so the store needs a rule, such as last-write-wins or keeping both versions.

Key takeaways

  • Single leader is simplest and conflict-free, but caps write throughput and needs failover
  • Design for replication lag: route reads that must be fresh to the leader
  • Multi-leader gives local writes per region at the cost of conflict resolution
  • Leaderless replication tolerates slow nodes without failover, using quorums and repair

Sign in to track lessons and earn badges.

Consistent hashingConsistency models

Coming up

Course: 0/24 lessons · 0/10 challenges0%

Build it on the canvas, pass the review (70+) and mark it complete to count it toward the course badge.

  1. 3/10Design a Hotel Booking SystemPrevent double booking with transactional holds and sagas while keeping availability search fast.Medium
  2. 4/10Design an Inventory ServiceKeep stock counts exact under concurrent orders using conditional updates, reservations and idempotent events.
Medium
All 10 challenges →