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.

Play a level

See it on the board

The same traffic runs on two boards. The simulator measured both when this page was built.

Board to show
SQLSQLUsersUsersPostgres1 vCPU · 2 GB × 4
SQLSQLUsersUsersPostgres1 vCPU · 2 GB × 4
Async, ack before copies: misses a goal
SQLSQLUsersUsersPostgres1 vCPU · 2 GB × 4
SQLSQLUsersUsersPostgres1 vCPU · 2 GB × 4
Semi-sync, ack after one follower: meets the goals
See it on the board
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

Default part values from the catalog. The mini board has 4 copies and a primary that fails at 0:40.
NumberValue
Default replica lag0.1 s
Disk sync time for one commit0.4 ms
Recovery time after a failure30 s
Copies and the write quorumDrag or use arrow keys to change the write quorum

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.