Semi-sync promotion
After a primary fails, promote only a copy that has every acknowledged write. Semi-sync replication waits about 100 ms for the fastest follower. Async can lose writes, and full sync waits 500 ms for the slow follower.
See it on the board
The same traffic runs on two boards. The simulator measured both when this page was built.
| Measure | Goal | Async, ack before copies | Semi-sync, ack after one follower |
|---|---|---|---|
| Lost writes | none | 50 Fail | 0 Pass |
| Availability (Reads) | at least 100% | 100% Pass | 100% Pass |
| Availability (Writes) | at least 99.5% | 100% Pass | 100% Pass |
| p99 latency (Writes) | under 250 ms | 4.6 ms Pass | 105 ms Pass |
| CPU use | under 80% | 20.2% Pass | 20.2% Pass |
| Monthly cost | 32 USD/mo | 32 USD/mo | |
| Error rate | 0% | 0% |
Key numbers
| Number | Value |
|---|---|
| Default replica lag | 0.1 s |
| Disk sync time for one commit | 0.4 ms |
| Recovery time after a failure | 30 s |
Quorum 2 of 3 · commit 9.0 ms
How it works
A write is acknowledged when the client is told it is safe. If the primary fails after that, the new primary must have the write. If it does not, the system loses an acknowledged write, and the client was lied to.
Async replication acknowledges a write when the primary has it. Followers get it later. If the primary fails at the wrong time, the followers can miss writes that were acknowledged. In the mini board the primary fails at 0:40 and stays down, and async loses writes.
Full sync waits for every follower. Nothing is lost, but each write is as slow as the slowest copy. Here two followers apply writes after 100 ms and a third needs 500 ms, so each write waits 500 ms, and the write p99 passes the 250 ms limit.
Semi-sync waits for one follower, usually the fastest. It is a middle path. Each write waits about 100 ms. Every acknowledged write exists on at least two copies. After the failure, the system must promote a copy that has it, not just any copy.
This needs rules for the choice of the new primary: check the log position of each copy before the promotion.
In the levels you choose the replication mode and the new primary, and check lost writes and write latency.