Cutting OpenRaft Leader Read p50 From 2.3 s to 1.2 ms With Relaxed Reads
drmingdrmerDec 1, 2026View Markdown
Overview
Introduced in OpenRaft 0.10.1, relaxed reads let a linearizable read on the leader wait only for the leader's no-op to be applied, not for apply to catch up with commit. With 500 µs added to each apply batch, p50 read latency fell from 1.2–2.0 ms to 0.92–0.96 ms; when apply fell behind commit, from 2.3 s to 1.2 ms.
OpenRaft is an open-source Raft consensus library written in Rust. It handles leader election and log replication for applications, including Databend's Meta Service, which manages shared database metadata. This article examines a read-path optimization in OpenRaft: when can a leader return a linearizable read without waiting for the state machine to apply every committed entry? The answer matters to developers building replicated metadata services and other distributed systems with delayed state-machine apply.
OpenRaft 0.10.1 introduced relaxed reads. A relaxed read is a linearizable read on the leader that waits only until the current leader's no-op log entry is applied, rather than until the state machine has applied everything up to the CommitIndex. The no-op is the first log entry a leader writes after it is elected, so once the leader has been running for a while, its no-op has long been applied. A relaxed read therefore almost never waits for apply, and its result is still linearizable.
When state-machine apply is delayed, relaxed reads can reduce leader read latency. In OpenRaft's benchmark, when each apply batch takes an extra 500 µs, the p50 latency of reads on the leader drops from 1.2–2.0 ms to 0.92–0.96 ms. When each apply batch takes an extra 2 ms, apply falls behind commit: standard reads reach a p50 latency of 2.3 s, while relaxed reads stay at 1.2 ms.
The argument unfolds in three steps. First, a leader read waits only for the no-op; while the leader remains unchanged, the read is linearizable. Next, a leader steps down mid-read, exposing a case in which a later read returns an older value. Finally, the counterexample leads to the fix: followers apply only log entries that the leader has already applied. The article then covers the TLA+ checks, OpenRaft usage, benchmark results, and costs.

Step 1: Why the Leader's No-Op Is Enough While Leadership Holds
If reads run only on the leader, and the leader does not change while a read runs, then a read only needs to wait until the state machine has applied the current leader's no-op, not until the state machine reaches the CommitIndex.
A standard ReadIndex read waits for the CommitIndex. When the leader receives a read, it first records the current CommitIndex as the ReadIndex. Next, it confirms through a heartbeat or a lease that it is still the leader. Finally, it waits until the state machine has applied up to the ReadIndex, and only then queries the state machine. OpenRaft uses
max(noop, CommitIndex)
But linearizability does not require a read to wait for the CommitIndex. Linearizability requires a read to see every client write that was acknowledged before the read started, but it does not require the read to see client writes that have not been acknowledged yet; see Linearizable Transactions in Distributed Systems. Below the CommitIndex there can be client writes that are committed but not yet acknowledged. Those client writes overlap the read in time, so the read is linearizable whether or not it sees them.
Therefore a relaxed read runs on the leader and uses the current leader's no-op as its ReadIndex, instead of the CommitIndex. The leader still confirms its leadership through a heartbeat or a lease. As soon as the state machine has applied the no-op, the read queries the state machine.
As long as the leader does not change, a read that waits only for the no-op is linearizable:
-
The log entries that earlier leaders committed all come before the current leader's no-op. So once the state machine has applied the no-op, it has applied those log entries too, and the read is sure to see them.
-
A client write that the current leader has acknowledged was already readable from the leader's state machine before it was acknowledged, so the read is sure to see it as well.
-
Earlier reads also queried the same leader's state machine, and a state machine only moves forward, so a later read never sees an older state.
Point 2 rests on a premise: before a client write is acknowledged, its result must already be readable from the leader's state machine. The application's state machine guarantees this premise. For example, if a state machine makes the results of a batch of log entries visible only after the whole batch is applied, it must hold back the batch's client-write responses until those results are visible.
But the argument above assumes that the leader does not change. After a read confirms leadership and before it queries the state machine, the leader may already have stepped down.
Step 2: A Leader Change Lets a Later Read See an Older Value
Waiting only for the no-op is not enough. If the leader steps down after a read has confirmed leadership, then a read that starts after the leader change can see an older value than an earlier read saw.
In the counterexample below,
x
T

-
t1: A confirms leadership for the read
. The ReadIndex ofR_Ais no-op 10, which is already applied, butR_Apauses before it queries the state machine.R_A -
t2: A steps down, and B becomes the leader of term
. B commits and applies its own no-op 21.T+1 -
t3: B commits log entry 22, which sets
to 1. But B's apply stops at 21, soxis still 0 in B's state machine, and the client write of log entry 22 has not been acknowledged yet.x -
t4: B sends log entry 22 and CommitIndex 22 to A. Standard Raft does not require a follower to wait for the leader to apply first, so A, now a follower, applies log entry 22, and
becomes 1 in A's state machine.x -
t5:
resumes on A, readsR_A, and returns 1 to the client.x = 1 -
t6: Only after the client receives the result of
does it start the readR_Aon B. B confirms leadership, and the ReadIndex ofR_Bis no-op 21, which is already applied.R_B -
t7: B has not applied log entry 22 yet, so
readsR_B.x = 0
R_A
R_B
R_B
R_A
R_B
R_A
R_A
x = 1
R_B
R_B
The root cause is that A, which became a follower when it stepped down, applied log entry 22 before the current leader B did, and
R_A
R_A
R_B
Standard ReadIndex prevents this regression. With standard ReadIndex, the ReadIndex of
R_B
R_B
R_B
x = 1
Step 3: Keep Follower Apply Behind the Leader
The counterexample in step 2 comes from a follower that applies a log entry before the current leader does. So the fix is to let a follower apply only the log entries that the leader has already applied.
The fix changes the apply limit that the leader sends to followers. In standard Raft, the leader sends its CommitIndex to followers in append entries and heartbeats, and a follower may apply up to that CommitIndex. With the fix, the leader instead sends the smaller of its own CommitIndex and AppliedIndex,
min(CommitIndex, AppliedIndex)
Back to the counterexample in step 2: at t4, B allows A to apply only up to 21, the index that B has applied, so A cannot apply log entry 22 before B does, and
R_A
x = 0
x = 1
R_B
x = 1
The argument extends across leader changes. With the fix, every log entry that any node applies has already been applied by the leader of that time. Therefore, wherever an earlier read ran, each log entry it saw has either been applied by the current leader already, or belongs to an earlier term and comes before the current leader's no-op. So a read on the current leader that waits only for the no-op is sure to see the state that earlier reads saw, and the conclusion of step 1 still holds after a leader change.
The fix leaves Raft's commit rule unchanged: a quorum still determines commit, while followers apply later.
The original consensus-essence article also gives another fix: only the leader serves reads, and if the last log entry that a read sees has a newer term than the term in which the read confirmed leadership, the read discards its result and reads again.
Why Relaxed Reads Apply Only to Leader Reads
A relaxed read takes effect on the leader that issues the read. If an application lets the leader confirm leadership and then hands the read to a follower, the follower uses the standard ReadIndex even when the application requested a relaxed read: the follower waits until its own state machine has applied up to
max(noop, CommitIndex)
Check the Counterexample and Fix With TLA+
The conclusions of all 3 steps are checked with the TLA+ model RelaxedReadApplied.tla. The checked bounds are 3 nodes, up to 3 terms, up to 4 log entries and 2 reads. Within these bounds, TLC explored every state and found no execution that violates linearizability.
Control experiments show that each rule below is necessary: when any one of them is removed, TLC finds an execution that violates linearizability.
-
The fix in step 3: if the leader sends its CommitIndex to followers, TLC finds exactly the counterexample of step 2.
-
Every node follows the fix of step 3: if only some nodes follow the fix when they lead, TLC also finds a violation.
-
The premise of step 1: if a client write is acknowledged after it commits but before its result is readable from the state machine, TLC also finds a violation.
TLC's results cover the bounds above: this is bounded model checking, not a proof for clusters of any size. The TLA+ verification report lists every case and its bounds.
Enable Relaxed Reads in OpenRaft
To enable relaxed reads, first change the config of every node, and then change the application's reads.
toSome(true)
Then the application requests a relaxed read with
:// Confirm leadership with a lease, and request a relaxed read
let option = LinearizerOption::from(ReadPolicy::LeaseRead).with_relaxed(true);
// On return, the local state machine has applied at least the current leader's no-op
raft.ensure_linearizable(option).await?;
// state_machine is the application's own state machine
let value = state_machine.read().await.get("key").cloned();
On a node without
enable_relaxed_read
max(noop, CommitIndex)
Benchmark Results: Faster Leader Reads When Apply Lags
A relaxed read skips the wait for apply to catch up with the CommitIndex, which can reduce leader read latency when apply is delayed.
OpenRaft's benchmark runs 3 voters in 1 process, with the log and the state machine in memory. In total, 64 reader clients send 90,000 reads per second, and 32 writer clients send 10,000 client writes per second. All reads run on the leader and confirm leadership with a lease. To simulate a delayed apply, the benchmark makes each apply batch spend extra time before it reads its log entries; this article calls that extra time the apply delay. Each number in the table below is the median of 3 runs:
| Apply delay | Standard read p50 / p99 | Relaxed read p50 / p99 |
|---|---|---|
| 0 | 1.25 ms / 2.51 ms | 1.25 ms / 2.44 ms |
| 500 µs | 2.01 ms / 6.04 ms | 0.92 ms / 2.06 ms |
| 2 ms | 2.32 s / 3.16 s | 1.21 ms / 3.32 ms |
-
With a 500 µs apply delay, the p50 of relaxed reads drops below half that of standard reads. Relaxed reads are also more stable: in 2 other test groups, standard reads had a p50 of 1.21 ms and 1.24 ms, while relaxed reads stayed at 0.92–0.96 ms in all 3 groups.
-
With a 2 ms apply delay, apply cannot keep up with commit, and the number of unapplied log entries keeps growing for the whole run. A standard read waits until those log entries are applied, so its p50 reaches 2.32 s; a relaxed read waits only for the no-op, so its p50 stays at 1.21 ms.
-
The apply delay can also happen while the state machine holds its write lock, and then a read also waits for that lock. In that case relaxed reads still lower the p50: from 2.11 ms to 1.39 ms with a 500 µs apply delay, and from 2.55 s to 2.08 s with a 2 ms apply delay.
-
With no apply delay, both kinds of reads have the same latency. Read latency is measured from the time each read is scheduled to start and includes the time the read waits in the client, so the p50 is about 1.2 ms even with no apply delay.
relaxed-reads-results.md has all the data and the test method.
Trade-Offs and Limitations
The main cost of relaxed reads comes from the fix in step 3: a follower waits for the leader to apply first, so followers apply a little later.
-
Reads on followers get slower. A follower now applies an entry about one leader apply plus one message delay after the leader does, so standard reads on a follower also wait that much longer. But the slowdown in the benchmark is far larger than one leader apply plus one message delay: with a 500 µs apply delay, the p50 of standard reads on a follower rises from 1.8 ms to 95 ms, and when the apply delay happens while the state machine holds its write lock, the p50 rises from 2.0 ms to 336 ms. The cause of the slowdown is still under investigation. Until the cause is found, we recommend that applications that read on followers hold off on enabling
.enable_relaxed_read -
Standard reads on the leader also get slightly slower. With
on, even reads that do not request a relaxed read had up to 15% higher p50 on the leader, in the test with a 500 µs apply delay that happens while the state machine holds its write lock. Client writes have no measurable extra cost.enable_relaxed_read
When Relaxed Reads Make Sense
Relaxed reads remove a wait that linearizability does not require: a read on the leader waits for the current leader's no-op, rather than for apply to catch up with the CommitIndex. This is safe while leadership remains unchanged. If a leader steps down mid-read, a later read can see an older value unless followers apply only entries already applied by their leader. When apply is delayed, relaxed reads can substantially reduce leader read latency. The trade-off is delayed follower apply; the benchmark also shows a substantial slowdown for follower reads that remains under investigation. Relaxed reads are therefore best suited to applications with delayed apply and reads concentrated on the leader.
Acknowledgments and References
The relaxed read design was proposed by neog24.
-
OpenRaft issue #1267: the proposal and its discussion.
-
OpenRaft PR #2317: the implementation of relaxed reads.
-
ReadIndex: Less Latency through Relaxed Ordering: the description and proof of the design.
-
RelaxedReadApplied.tla and the TLA+ verification report: the TLA+ model and the check results.
-
Opt-in relaxed leader reads: relaxed reads in the OpenRaft documentation.
-
relaxed-reads-results.md: all benchmark results.
Subscribe to our newsletter
Stay informed on feature releases, product roadmap, support, and cloud offerings!



