What it is
In multi-leader replication (also called multi-master or active–active) more than one node accepts writes. Each leader applies writes from its own clients and forwards them to the other leaders, which apply them as if they were followers. The typical layout is one leader per region or data centre; other forms are offline-first apps (every device is a leader that syncs later) and collaborative editors (every open document is a replica that accepts edits).
Why it exists
With a single leader, every write has to reach that one node. For users in another region that means a cross-region round trip on every write, often 100–200 ms or more, and if the link between regions breaks, writes from the far side fail. Read replicas in the far region help reads, not writes.
A leader in each region removes both problems: writes are acknowledged locally, and each region can keep working when it cannot reach the others.
How it works
Local writes, asynchronous replication. A leader commits a client's write locally and answers. It then ships the change to the other leaders, usually asynchronously; waiting for a remote leader would bring back the latency that multi-leader is meant to remove. In the lesson the link is 70 ms one way, and the other region sees each write about 70 ms after it was acknowledged.
Eventual consistency across regions. Until a change arrives, the other region serves the old value. Within a region things look normal; across regions there is no point in time at which all leaders agree, only convergence once writes stop.
Conflicts. Two leaders can accept writes to the same key before either has seen the other's. Such writes are concurrent: neither happened after the other in any causal sense. If each leader simply applies writes in arrival order, the leaders end with different values and stay that way.
Conflict resolution. Every multi-leader system needs a rule that makes all replicas end up with the same value:
- Last write wins (LWW). Each write carries a timestamp; the highest wins everywhere. Simple and convergent, but every other concurrent write is discarded even though its client was told it succeeded. Timestamps come from clocks on different machines, so skew decides which write survives. (Hybrid logical clocks reduce, but do not remove, that arbitrariness.)
- CRDTs. Conflict-free replicated data types (counters, sets, maps, registers, sequences for text) define a merge that is commutative, associative and idempotent, so replicas that have seen the same updates converge regardless of order, and no update is lost. A shopping cart as an observed-remove set keeps both "book" and "lamp" when two regions add them at once.
- Application merge or siblings. The database keeps all concurrent versions and hands them to the application (or user) on the next read. Riak's siblings and CouchDB's conflict revisions work this way.
- Custom resolvers. Some databases run a resolver function when they detect a conflict (for example a stored procedure in Azure Cosmos DB, whose default policy is LWW on a timestamp).
Topology. With more than two leaders, changes travel all-to-all, in a ring or a star. Ring and star topologies need loop prevention (each change carries the IDs of nodes it has passed) and break if one node fails; all-to-all can deliver changes out of causal order, which version vectors detect.
When to use it
- Writes from several regions where local write latency matters and the data tolerates eventual consistency (user preferences, carts, content edits, social interactions).
- Regions that must stay writable during a partition between them.
- Offline-first and collaborative applications, where each device or session must accept edits without a network.
When not to
- Data with invariants across records or replicas: balances that must not go negative, unique usernames, seat or stock reservations. Two leaders can each approve the last seat. Use a single leader (or consensus) for that data.
- When one region does almost all writes. A single leader there plus read replicas elsewhere is simpler and loses nothing.
- When the team cannot define a resolution rule for every kind of data. Multi-leader without a deliberate conflict strategy means LWW by default, and silent data loss.
Trade-offs
| Choice | You gain | You pay |
|---|---|---|
| Single leader, replicas elsewhere | No write conflicts, simple reasoning | Cross-region latency on every remote write; remote writes fail during a partition |
| Multi-leader with LWW | Local writes, always writable, convergence for free | Concurrent writes silently lost; clock skew picks the survivor |
| Multi-leader with CRDTs | Local writes, no lost updates | Only for data that fits a CRDT; metadata overhead (tombstones, version vectors) |
| Multi-leader with siblings / app merge | Nothing lost, merge logic of your choice | Every reader must handle conflicts; merge code is easy to get wrong |
| Home region per record | Local writes for most users, no conflicts | Writes for a record from another region pay the trip to its home; rehoming is work |
Alternatives
- Single leader with read replicas (see database replication) when writes come mostly from one place.
- Home region per record: every user or account has one region whose leader takes its writes. Most writes are local, and there is never more than one leader per record.
- Leaderless replication with quorums (Dynamo-style) accepts writes on any replica, with the same need to version and merge concurrent writes.
- Consensus-based distributed SQL (Spanner, CockroachDB, YugabyteDB): writes are linearizable across regions, at the cost of a cross-region round trip for each write to a majority.
Failure modes
- Silent lost updates under LWW. Both users saw "saved"; one change is gone, with no error anywhere.
- Clock skew. A node whose clock runs ahead wins every LWW conflict, and may even shadow later writes until real time catches up.
- Divergence from missing resolution. Without a rule, or with a rule that is not deterministic on every replica, replicas disagree permanently.
- Constraint violations. Unique indexes and foreign keys are checked per leader; two leaders can each insert the same "unique" value.
- Backlog after a partition. Everything written during an outage must be shipped and resolved when it heals, a burst of replication traffic and conflicts at once.
- Causality violations. In all-to-all topologies a follower can receive an update before the insert it depends on.
In production
Examples of multi-leader or multi-region-write systems: Azure Cosmos DB with multi-region writes, DynamoDB global tables (last writer wins in the multi-active mode; a strongly consistent multi-Region mode also exists), CouchDB/PouchDB sync, Redis Enterprise Active-Active (CRDT-based) and EDB Postgres Distributed (BDR). Collaborative editors use CRDT libraries such as Automerge or Yjs.
Teams that run it well decide the resolution per data type before launch, keep must-be-unique and must-not-overdraw data on a single leader, monitor replication lag between regions, and test partitions deliberately to see how many conflicts a realistic outage produces.
Common misconceptions
- "Multi-leader doubles write capacity." Every write is still applied on every leader. It reduces latency and adds availability, not throughput per replica.
- "Conflicts are rare, so they don't matter." They are rare per key and certain at scale, and they cluster on the hottest keys during outages, exactly when you can least afford surprises.
- "Last write wins means the newest write wins." It means the highest timestamp wins, from clocks that disagree.
- "CRDTs solve every conflict." They merge data structures; they cannot enforce invariants such as "never below zero" without coordination.
Interview angle
Bring up multi-leader when a design needs low-latency writes in several regions or offline clients. Then address conflicts before the interviewer does: which data can be merged (counters, sets: CRDTs), which can tolerate LWW (last-seen timestamps), and which must stay on a single home region (payments, inventory, unique names). Mention that cross-region reads are eventually consistent and how you would hide that from users (read-your-writes by routing a user to their home region).
Model assumptions
The engine parts of this lesson are a simplified model, not a benchmark. Two regions are 70 ms apart one way; within a region a hop takes 2 ms. Each region's app tier sends 150 queries per second (Poisson arrivals), 30% writes, over the same 40 keys with a Zipf(1.0) popularity. Every database has 16 connections, a 10 ms mean read and a 20 ms mean write (lognormal, cv 0.4). With two leaders, each leader acknowledges a local write at once and ships it to the other over the 70 ms link (asynchronous replication in both directions); applying it costs nothing. A read counts as stale when the other region had already acknowledged a newer write for that key. The conflict, last-write-wins and CRDT steps are scripted illustrations: the engine tracks keys and times, not values, and does not detect or resolve conflicts. Also not modelled: shipping the backlog after a partition (the simulation simply resumes replication), clock skew, and more than two leaders. Numbers show behaviour and orders of magnitude only.