Replication and lag lab
A leader streams writes to followers over a network that is slow and uneven. Pick when the leader acknowledges, watch lag, write latency and stale reads, then kill the leader.
lag = now − time of the oldest write a follower lacks3 followers, one-way delay 20 msleader acknowledges after: its own disk
Asynchronous, lag per follower (ms)
- write latency
- 1.0ms
- p99 write
- 1.0ms
- stale reads
- 55.1%
- acked writes lost
- 0
| Series | Latest | Lowest | Highest |
|---|---|---|---|
| Asynchronous | 11.7 | 0.0 | 32.9 |
| Series | Latest | Lowest | Highest |
|---|---|---|---|
| Asynchronous | 62% | 17% | 68% |
Reads under: Any follower, at random
- stale reads
- 55.1%
- own write missing
- 6.5%
- went back in time
- 0.5%
- served by leader
- 0%
Stale means older than the newest acknowledged write. Own write missing means a client did not see a write it had been told succeeded. Went back in time means a client saw an older value than one it read before.
| Mode | Mean write latency (ms) | p99 write (ms) | Stale reads | Lag per follower (ms) | Acked writes lost |
|---|---|---|---|---|---|
| Asynchronous | 1.0 | 1.0 | 55.1% | 35.2 0.0 0.0 | 0 |
What to try
Each one sets up a starting point. Then make the change it describes.
Three ways to acknowledge
Pick Compare all replication modes and let it run. Read write latency, stale reads and the lag bars in each panel.
Look for. Asynchronous answers fastest and leaves followers behind. Synchronous waits for a round trip to the slowest follower and leaves reads from followers fresh. Semi-synchronous sits between them.
Kill the leader
Keep Compare all replication modes, raise the write rate to 100 per second, then press Fail the leader now. Read the acknowledged writes lost in each panel.
Look for. Writes the leader acknowledged but had not yet sent to the promoted follower are gone under asynchronous replication. Semi-synchronous and synchronous replication lose none, because an acknowledged write was already on a follower.
A slower network
Stay in asynchronous mode and raise the mean network delay from 20 to 150 ms. Then switch to synchronous.
Look for. Asynchronous lag and stale reads grow with the delay, but the write latency does not move. Synchronous replication does the opposite: reads stay fresh and every write pays the delay twice.
Read your own writes
Use asynchronous replication with 80 ms of delay and reads sent to any follower. Look at "own write missing". Then change where reads go to "Follower, leader if behind my last write".
Look for. With random followers some clients fail to see a write they were just told succeeded. Sending a read to the leader when the follower is behind your last write removes that, at the price of more leader reads.
Reads that go back in time
With 80 ms of delay, compare "Any follower, at random" against "One fixed follower per client" and read "went back in time".
Look for. Two reads from different followers can show a newer value and then an older one. Pinning a client to one follower stops that, because one follower only moves forward. It does not stop the follower being behind.
New to the idea? Read the lesson first. Every number here comes from a seeded simulator, so the same seed gives the same run.
Your progress is saved in this browser. Sign in to keep it on every device. Privacy · Terms