FiveFamilies

Numbers from the laptop (i7-1270P, Docker Desktop on WSL2, a Samsung PM9A1 NVMe), five nodes in containers, each result committed with the code that produced it. The design notes behind them, including what didn't work, are in the repository.

How long a succession takes

The Don is killed with SIGKILL under 200 writes a second, ten times per election timeout. The gap is the widest silence between two acknowledged writes, as a client sees it.

election timeoutclients waited, medianrangenew Don chosen after
150ms194 ms179–233 ms178 ms
300ms378 ms352–714 ms355 ms
600ms706 ms641–814 ms713 ms
1s1,206 ms1,122–1,449 ms1,173 ms

What a short election timeout costs

No family is killed here. Under a steady 300 writes a second, a disk stall or a frozen event loop is forced on the Don or a follower five times each, and the table counts how many of those were followed by a succession that shouldn't have happened.

faulttimeout 150 mstimeout 300 mstimeout 600 mstimeout 1,000 ms
disk stall of 100 ms on the leader0 of 50 of 50 of 50 of 5
disk stall of 300 ms on the leader0 of 50 of 50 of 50 of 5
disk stall of 1,000 ms on the leader0 of 50 of 50 of 50 of 5
disk stall of 1,000 ms on the follower0 of 50 of 50 of 50 of 5
pause of T/2 on the leader0 of 50 of 50 of 50 of 5
pause of T on the leader0 of 50 of 50 of 50 of 5
pause of 2T on the leader5 of 55 of 55 of 55 of 5
pause of 2T on the follower0 of 50 of 50 of 50 of 5
fault, storage waited on in the looptimeout 300 mstimeout 1,000 ms
disk stall of 100 ms on the leader0 of 50 of 5
disk stall of 300 ms on the leader0 of 50 of 5
disk stall of 1,000 ms on the leader5 of 50 of 5

Throughput and latency

Open-loop writes on a quiet cluster, doubling the rate until a step falls behind (under 90% of the offered rate, p99 over a second, or more than 1% failed), then two steps of bisection. The knee is the highest rate that kept up. Where a row ran three interleaved rounds, the knee is the median with the range. Latency comes from a run at 80% of the knee, or the nearest lower step that kept up.

configurationknee, writes/slatency taken atp50p99fsyncs per writemessages per write
5 nodes5,000 (4,000–6,000)4,00015 ms65 ms0.158.5
3 nodes8,000 (7,000–8,000)6,40036 ms75 ms0.063.9
7 nodes6,000 (every round)4,80046 ms80 ms0.1312
5 nodes, one entry per append5,0004,00045 ms79 ms0.138.3
5 nodes, no pipelining8,0004,00013 ms36 ms0.170.29
5 nodes, 1 KiB values5,0004,00034 ms444 ms0.158.3
5 nodes, no cap on pending writes7,000 (6,000–7,000)5,60041 ms155 ms0.097.7
5 nodes, one event per Ready7,0005,60044 ms78 ms0.1015
10 ms100 ms1 s10 s5001k2k4k8k16koffered per second
5 nodes3 nodes7 nodes5 nodes, no pipeliningp99 latency (hollow points fell behind)

Three nodes stay ahead (7,000 to 8,000). Five and seven overlap, and the same five-node setup ranged from 4,000 to 7,000 over six rounds that evening. Taking the whole queue into one Ready halved the messages per write but didn't move the knee: one event per Ready reached 7,000 too. Without pipelining the appends wait for each other and carry dozens of entries, which reached 8,000 in its one round. Past the knee the cluster still collapses rather than slowing down, with or without the cap on pending writes.

What durability costs

The same five nodes with different fsync policies on the NVMe under WSL2. "No fsync" is unsafe and only here as a floor.

configurationknee, writes/slatency taken atp50p99fsyncs per writemessages per write
group commit5,0004,00041 ms73 ms0.138.2
one fsync per write1108811 ms15 ms5.018
one fsync per entry1108811 ms16 ms5.018
no fsync (unsafe)24,00019,2004.4 ms41 ms07.8
group commit, leader writes before sending4,0003,20018 ms29 ms0.215.1

A flush takes about 9 ms on this disk, so one per write holds every node to about 110 writes a second. Group commit flushes about 40 entries at once near its knee. At low load the flush is nearly all of a write's latency: 13 ms with it, under a millisecond without. Writing on the leader before sending its appends reached 4,000 against 5,000 for writing in parallel, and added about 3 ms at low load (15.4 against 12.8 ms).

Four ways to read

Reads through the log, ReadIndex, the leader's lease and ReadIndex on followers, at 95% and 50% reads. The unsafe local read is a planted bug, here as a floor.

read path and shareknee, ops/slatency taken atread p50read p99write p99messages per op
lease reads, 0.9516,000 (every round)12,80011 ms47 ms94 ms0.47
index reads, 0.9512,000 (every round)9,60026 ms73 ms80 ms14
follower reads, 0.9520,00016,00035 ms279 ms253 ms5.1
log reads, 0.956,0004,80042 ms69 ms68 ms8.2
local reads (unsafe), 0.9532,00025,6000.6 ms71 ms153 ms3.3
lease reads, 0.58,0006,4000.7 ms26 ms56 ms4.4
index reads, 0.55,0004,00033 ms72 ms81 ms12
follower reads, 0.54,0003,20027 ms85 ms93 ms10
log reads, 0.55,0004,00039 ms66 ms66 ms8.2
local reads (unsafe), 0.510,0008,0000.6 ms56 ms67 ms5.7
index reads, 0.95, one event per Ready8,0006,40027 ms107 ms109 ms16
index reads, 0.5, one event per Ready4,0003,20027 ms429 ms435 ms15

A lease read answers in a third of a millisecond and costs no messages until the leader is busy with writes. ReadIndex reached 12,000 in all three rounds against the lease's 16,000: reads that queue up share a heartbeat round, though below the knee one still costs about 14 messages, because there is rarely more than one waiting. ReadIndex on followers reached 20,000, more than the lease, because the reads themselves leave the leader. With half the operations writes, every path is limited by the writes.

Next to etcd

etcd 3.6.15 with the same timeouts, CPU pinning and load. etcd keeps a full MVCC history on disk and FiveFamilies keeps its state in memory, so FiveFamilies does less work per write.

configurationknee, ops/slatency taken atp50p99fsyncs per opmessages per op
fivefamilies, 3 nodes, writes6,0004,80035 ms67 ms0.084.1
etcd, 3 nodes, writes24,00019,20053 ms176 ms0.02not counted
fivefamilies, 5 nodes, writes6,000 (6,000–7,000)4,00015 ms60 ms0.158.5
etcd, 5 nodes, writes16,000 (16,000–20,000)12,80052 ms135 ms0.04not counted
etcd, 5 nodes, writes, client on the leader only12,0009,60029 ms94 ms0.06not counted
fivefamilies, 5 nodes, ReadIndex reads 0.9512,0009,60025 ms62 ms0.0614
etcd, 5 nodes, linearizable reads 0.9532,00025,60078 ms162 ms0.02not counted
fivefamilies, 5 nodes, local reads (unsafe) 0.9540,00032,0000.8 ms119 ms0.013.0
etcd, 5 nodes, serializable reads 0.9532,00025,6001.2 ms60 ms0.02not counted
10 ms100 ms1 s10 s5001k2k4k8k16k32koffered per second
fivefamilies, 3 nodes, writesetcd, 3 nodes, writesfivefamilies, 5 nodes, writesetcd, 5 nodes, writesp99 latency (hollow points fell behind)

etcd still wins on everything that goes through consensus: 2.7 times the writes on five nodes and 4 times on three, 2.7 times the linearizable reads. FiveFamilies' unsafe local reads beat etcd's serializable ones (40,000 against 32,000), and at low load FiveFamilies writes faster (11 to 13 ms against 23 to 37 ms). Past their knees etcd slows down and keeps answering, but FiveFamilies falls over. etcd's five-node write median is a lower bound: in one round the step above it was ruled invalid because the load generator itself fell behind.

Taking the whole queue into one Ready

After the runs above, the server loop takes everything queued, up to 256 events, before it asks Raft for a Ready. One event per Ready is the old behaviour, kept as a switch for this comparison, and both ran back to back on the same evening.

configurationknee, ops/slatency taken atp50p99fsyncs per opmessages per op
writes, queue taken in one Ready6,0004,00027 ms66 ms0.148.4
writes, one event per Ready5,0004,00044 ms80 ms0.1316
ReadIndex at 95% reads, queue taken in one Ready14,00011,20033 ms96 ms0.0413
ReadIndex at 95% reads, one event per Ready8,0006,40026 ms160 ms0.0716

ReadIndex gained the most: reads that queue up share a heartbeat round, the knee went from 8,000 to 14,000, and offered 16,000 a second the cluster still served 13,178 instead of 27. Writes send about half the messages (8 against 15 per write at 4,000 a second), but their knee moved by less than run-to-run noise, so something else holds writes back.

Where the time goes

Go profiles of the Don under steady writes on five nodes. At 4,000 writes a second it used 54% of its CPU, and half of that went to write syscalls flushing gRPC streams, mostly to the followers. The loop with Raft, the store and the bookkeeping was 6%. At 6,000 a second it used 39%, with bigger batches and fewer flushes, and its request handlers spent their time waiting for commits, not for locks. So CPU time doesn't set the knee.

Overloaded at 10,000 writes a second for 15 s, the cluster served 218 a second. With the Don refusing writes past 4,096 uncommitted entries it served 267, with 5,099 refusals and 85,629 timeouts: the cap bounds the queue inside Raft, but most writes waited in front of the event loop (refusing once that queue is full came later). After both overloads it went back to 4,000 a second cleanly.

How long a dead service stays listed

An instance registered with a 2 s lease is killed, and a client watching the registry times how long it still sees it. A new Don gives every lease its full time again, so losing the Don as well adds an election.

what diedmedianminmaxkills
the instance1,750 ms1,475 ms2,078 ms10
the instance and the Don3,184 ms3,066 ms3,365 ms10

Real faults, checked

Kills, pauses, partitions, slow links, membership changes and leadership handovers on a real five-node cluster, with every client operation recorded and the whole history checked for linearizability afterwards.

runfaultsoperationslinearizablestates equal
20261015-seed2-3m27 in 180 s41,208yesyes
20261016-seed3-3m-members27 in 180 s48,902yesyes
20261016-seed4-3m-membership-heavy32 in 180 s49,766yesyes
20261017-seed5-3m32 in 180 s51,012yesyes
20261017-seed6-3m-members30 in 180 s49,896yesyes
20261017-seed7-3m-membership-heavy39 in 180 s46,732yesyes

Bugs planted on purpose

The same checks against builds with a known bug switched on, to show what the net catches on a real cluster and what it doesn't. The simulator catches every one of them. These runs were 90 seconds each.

bugoperationslinearizablestates equalcaught
anyvote2,002Illegalnoyes
figure820,026yesyesnot in 90 s
prevterm23,129yesyesnot in 90 s
staleterm21,504yesyesnot in 90 s
anyvote15,937Illegalyesyes
figure824,218yesyesnot in 90 s
prevterm25,794yesyesnot in 90 s
staleterm23,086yesyesnot in 90 s