Leader-follower, multi-leader and leaderless: who is allowed to accept a write?
Every replicated database must answer one question: who is allowed to accept a write? There are three main answers, and each one changes how the system behaves when things go wrong.
The page on Replication explains why we keep copies. This page goes one step deeper: how are the copies kept in step? The answer depends on who may write.
In single-leader replication, all writes go to one node, the leader. It puts them in one order in its log, and the followers replay that log. Because there is a single place that decides the order, every copy ends up the same.
In multi-leader replication, each region has its own leader. A user in Europe writes to the EU leader and a user in the US writes to the US leader, so both are fast. The leaders then send their writes to each other. If two users change the same row at the same time, the leaders disagree, and the system needs a rule to settle it.
In leaderless replication, there is no special node. A client (or a coordinator node) sends each write to several replicas and reads from several replicas. If enough of them answer, the operation counts as done. The rule for "enough" is a quorum.
| Mode | Leader waits for | Effect |
|---|---|---|
| Asynchronous | Nothing | Fast. A leader crash can lose the newest confirmed writes, and followers can lag. |
| Semi-synchronous | One follower | A second copy of every confirmed write exists. A common middle choice. |
| Synchronous | All followers | Safest, but one slow or dead follower stalls every write. |
When the leader fails, a follower must be promoted. The system detects the failure (missed heartbeats), picks the most up-to-date follower, redirects clients, and must stop the old leader from accepting writes if it comes back. If it does not, you get a split brain.
| Rule | How it works | Watch out |
|---|---|---|
| Avoid conflicts | Route all writes for one record to the same leader (for example by user's home region) | Breaks down when that region is down or the user travels |
| Last write wins (LWW) | Keep the value with the latest timestamp | Clocks are never perfect, and the losing write is silently thrown away |
| Merge | Combine both values with a rule that always gives the same answer on every node (CRDTs) | Only works when the data type can be merged |
| Keep both and ask | Store both versions as siblings, and let the application or the user choose | The application must handle the extra work |
A simplified story with fixed outcomes and no random numbers. Real systems also use clocks, version vectors and background repair. Last-write-wins depends on clocks, which can be wrong by a little, so it can drop the "wrong" write.
| Term | Meaning in easy words |
|---|---|
| Leader / primary | The node that accepts writes (in leader-based models) |
| Follower / replica | A node that copies another node's changes |
| Single-leader | One node takes all writes; others copy it |
| Multi-leader | Several nodes take writes and copy each other |
| Leaderless | Any node takes writes; a quorum decides success |
| Write conflict | Two writes to the same data that did not see each other |
| Last-write-wins (LWW) | Keep the value with the latest timestamp and drop the other |
| Sibling | One of several conflicting versions kept side by side |
| Read repair | Fixing an old replica when a read finds it is behind |
| Hinted handoff | Holding a write for a down node and giving it back later |
| Anti-entropy | A background job that compares and repairs replicas |
| Choice | We gain | We lose |
|---|---|---|
| Single-leader | Simplicity and a clear order of writes | Write scale and write speed far from the leader |
| Multi-leader | Local writes in every region, offline writes | You must resolve conflicts |
| Leaderless | High availability for writes | Strong consistency, and you need repair |
| LWW conflict rule | Simple, always gives one answer | Can silently drop a write |
| Merge conflict rule | Nothing is lost | Only some data types can be merged |
| Sync replication | No loss of confirmed writes | Slower, and a slow follower can block writes |