When scaling Raft reads, batch ReadIndex heartbeats (or offload to Followers) for clock-free safety, and use Lease Reads only with bounded clock drift.
TL;DR30-second simplified summary▾
Batched ReadIndex achieves 100K+ RPS without WAL fsyncs or clock assumptions; Lease Reads cut latency to <1 ms when monotonic drift and GC/VM pauses are bounded.
CLOCK_MONOTONIC advances steadily within bounded hardware drift.P · Problem & The Deposed Zombie Leader Trap.
Suppose Node A is Leader of a 5-node Raft cluster (term 1, x = 1). A network partition isolates Node A from Nodes B, C, D, E.
Nodes B–E elect Node B as the new Leader (term 2) and commit x = 2. Meanwhile, Node A has not yet received any higher-term message, so it still believes it is Leader! Any client still connected to Node A that reads x locally gets x = 1—a stale read after x = 2 was already committed.
Log-Based Read (WAL fsync) vs. ReadIndex & Lease Read
- Local read returns stale x=1
- LogRead burns WAL fsync/read
- Read QPS capped by disk
- Zero WAL disk writes
- Quorum heartbeat or bounded lease
- 100K+ RPS linearizable reads
R · Representation: The 4-Step ReadIndex Protocol.
ReadIndex separates proving you are still Leader from writing to disk.
Step 1: Leader captures readIndex = commitIndex (and ensures it has committed at least one entry in its current term!). Step 2: Leader broadcasts a heartbeat with an incremental readCtx and waits for floor(N/2) + 1 acks. Step 3: Leader waits until its local applyIndex >= readIndex. Step 4: Leader reads its local state machine and replies.
Client -> Leader (Record commitIndex) -> Quorum Heartbeat -> Apply Wait -> Reply
I · Invariant: Bounded Monotonic Clock Lease Reads.
In Raft, Followers cannot start an election until election_timeout has elapsed since the Leader's last heartbeat.
If the Leader receives a majority quorum of heartbeat acks starting at t_start, no new Leader can be elected before t_start + election_timeout / max_clock_drift. Until that local monotonic deadline expires, the Leader can serve linearizable reads in <1 ms with zero network messages!
Quorum Ack -> Valid Lease (<1ms Local) -> Expired -> ReadIndex Fallback
M · Mechanics at Scale: ReadIndex Batching & Term-Commit Rule.
Under 100K RPS reads, sending 100,000 separate ReadIndex heartbeats per second would flood Followers.
Batch all concurrent ReadIndex requests arriving within a 1–2 ms window onto a single quorum heartbeat! One heartbeat proves leadership for all 200 waiting reads at once. Also, a brand-new Leader MUST commit a No-Op entry in its new term before serving ReadIndex, because Raft's commitIndex isn't guaranteed up-to-date until a current-term entry commits.
200 Concurrent Reads -> 1 Quorum Heartbeat -> Apply Wait -> Fan-Out Reply
- Problem
- How to scale linearizable Raft reads without WAL disk overhead or stale zombie-leader reads.
- Naive Solution
- Serve reads directly from Leader RAM without checks, or append every read to the Raft WAL.
- Why It Fails
- Unchecked local reads return stale data during partitions; WAL-logged reads cap read QPS at disk fsync speed.
- Alternatives
- LogRead vs. Batched ReadIndex vs. Monotonic Lease Read.
- Engineering Decision
- Default to Batched ReadIndex (plus Follower ReadIndex offload) in cloud VMs; enable Lease Read only when hardware monotonic clocks and GC pauses are strictly bounded.
- Trade-Offs
- ReadIndex pays ~1 intra-AZ heartbeat RTT (amortized across batches) in exchange for zero reliance on physical clock accuracy.
E · Edge Cases, Assumptions & When NOT to Use Lease Reads.
Lease Reads depend on a physical time assumption: that the Leader's monotonic clock advances at roughly the same rate as Followers' election timers.
When NOT to use Lease Reads: on garbage-collected runtimes with multi-second Stop-The-World pauses (e.g., un-tuned JVM) or cloud VMs subject to silent hypervisor live-migration pauses (>500 ms freeze). During a 2-second freeze, the Leader's monotonic clock can still appear valid locally right after wake-up while Followers already elected a new Leader!
Serializable (Fast, Stale OK) vs. ReadIndex (CP Safe) vs. Lease (Sub-ms)
Your 5-node Raft cluster runs on cloud VMs using Lease Reads (election_timeout = 1.0s, lease = 0.8s). A hypervisor live-migrates the Leader VM, freezing its CPU for 1.5 seconds. Why is Lease Read dangerous here?
Practice: Make the trade-off yourself.
Why can reading directly from a Raft Leader's local memory without ReadIndex or Lease Read return stale data?