Try
↑ ↓ move↵ openesc close

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

The most up-to-date follower takes over. Writes it never received are gone.

Asynchronous, lag per follower (ms)

write latency
1.0ms
p99 write
1.0ms
stale reads
55.1%
acked writes lost
0
Mean follower lag
Mean follower lag. Text version available below the chart.0.012.525.037.550.0t=0.0st=0.6st=1.2ssimulated timelag (ms)
Stale reads, last 0.5 s
Stale reads, last 0.5 s. Text version available below the chart.0%25%50%75%100%t=0.0st=0.6st=1.2ssimulated timeshare of reads

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.

What to try

Each one sets up a starting point. Then make the change it describes.

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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