Skip to content

RATIS-2524. Implement ReadIndex batching - #1715

Open
ivandika3 wants to merge 12 commits into
apache:masterfrom
ivandika3:RATIS-2524
Open

ivandika3 wants to merge 12 commits into
apache:masterfrom
ivandika3:RATIS-2524

Conversation

@ivandika3

@ivandika3 ivandika3 commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

Generated-by: GPT 6.1 Sol (PR description is hand-written).

Please see https://issues.apache.org/jira/browse/RATIS-2524 for the background. This improves on the the previous ReadIndex batching #1455 implementation by using natural / continuous / automatic batching (I will use natural batching from now on) instead of a fixed read batch size and interval.

The main class of the implementation is the ReadIndexBatching.

Follower read flows

  1. ReadRequestHandler#sendReadIndexAsync requests a ReadIndex by calling ReadIndexBatching#submit.
  2. ReadIndexBatching adds the pending ReadIndex invocation to its pending call and immediately schedule drain (i.e. natural batching will not wait until the batch size reaches a certain size and send as fast as possible to reduce the latency).
  3. drain will send a ReadIndex RPC to the leader and wait for the results.
  4. After the ReadIndex RPC is retrieved, ReadIndexBatching will complete the Completable<ReadIndexReplyProto> that the clients are waiting for
  5. Client sees that the ReadIndex barrier has finished and proceed to read locally

Design decisions

  • read-after-write requests will NOT use ReadIndex batching since the ReadIndex RPC requires to choose single client ID among all the ReadIndex requests while read-after-write requires client ID to be preserved.
  • ReadIndexBatching uses its own ThreadPool for sending ReadIndex RPC, draining, and completing so it doesn't contend with serverExecutor
  • We set the element limit so that a ReadIndex RPC does not wait for too long
  • We also allow increasing the number of inflight ReadIndex RPC. This can mitigates the issue where a slow ReadIndex RPC can cause head-of-line blocking to the subsequent ReadIndex RPC.
  • Disable ReadIndex batching implementation by default. However, it might be reasonable to not gate the ReadIndex batching with a configuration since systems like etcd already uses batching as its default implementation.

Advantages

  • Amortizes the cost of ReadIndex RPC which reduces the network overhead and bandwidth and OS interrupts due to OS packet. This can improve the average throughput and latency.

Drawbacks

  • Possible increased latency since ReadIndex requests does not trigger ReadIndex immediately (although Natural batching will try to serve ReadIndex batching immediately)
  • Reads are more bursty since reads in a batch are going to be executed at around the same time (instead of previously where reads are going to be served immediately as they arrive which can have a smoother distribution). This can increase things lock contentions due to the bursty reads.

Performance results

We saw sizeable improvements in the follower read throughput (although it's still well below the leader read performance) on Ozone Manager.

Setup

Cluster

  • 3 OMs: OM leader and followers are always the same
  • Freon tests with 0-sized key so the performance tests only measure metadata performance
  • Ratis configuration
    • raft.server.read.leader.heartbeat-check.enabled=false: Leadership heartbeat check disabled
    • raft.server.read.read-index.type=APPLIED_INDEX: Use appliedIndex as read index to reduce apply latency
    • raft.server.read.read-index.batch.enabled=true: Enable ReadIndexBatch
  • Client
    • Colocated with the same OM follower
    • 100 client threads

Results

OP Mode Mean Write QPS Write QPS speedup (vs Baseline) Mean Read QPS Read QPS speedup (vs Baseline) P99 Write latency (ms) P99 Read latency (ms)
READ_KEY Leader read (baseline) N/A N/A 235,020.55 1.0000 N/A 1.477595
READ_KEY Batching disabled N/A N/A 156,767.86 0.6670 3.511545
READ_KEY Batching enabled N/A N/A 162,638.62 0.6920 1.266164
CREATE_KEY,READ_KEY 10%,90% Leader read (baseline) 1,365.69 218,236.41 12.449381 1.459514
CREATE_KEY,READ_KEY 10%,90% Batching disabled 6,085.91 4.4563 43,035.35 0.1972 3.084175 11.85607
CREATE_KEY,READ_KEY 10%,90% Batching enabled 6,195.40 4.5365 66,489.96 0.3047 4.284225 4.818169
CREATE_KEY,READ_KEY 30%,70% Leader read (baseline) 2,177.63 181,877.78 19.874166 0.905082
CREATE_KEY,READ_KEY 30%,70% Batching disabled 9,167.05 4.2096 10,458.07 0.0575 5.586502 109.034817
CREATE_KEY,READ_KEY 30%,70% Batching enabled 8,138.04 3.7371 36,321.30 0.1997 6.355364 11.007342
CREATE_KEY,READ_KEY 90%,10% Leader read (baseline) 6,899.44 37,131.68 17.001288 0.396753
CREATE_KEY,READ_KEY 90%,10% Batching disabled 9,170.18 1.3291 6,460.76 0.1740 18.140096 4.184204
CREATE_KEY,READ_KEY 90%,10% Batching enabled 9,186.71 1.3315 7,269.17 0.1958 12.897366 3.693773
CREATE_KEY,READ_KEY 70%,30% Leader read (baseline) 4,794.36 94,964.18 17.304544 0.527844
CREATE_KEY,READ_KEY 70%,30% Batching disabled 9,170.18 1.9127 6,460.76 0.0680 18.140096 4.184204
CREATE_KEY,READ_KEY 70%,30% Batching enabled 8,754.77 1.8261 19,391.86 0.2042 13.704982 6.734598
CREATE_KEY Leader read (baseline) 9,747.37 N/A N/A 13.7777 N/A
CREATE_KEY Batching disabled 9,328.98 0.9571 12.835864 N/A
CREATE_KEY Batching enabled 9,363.38 0.9606 12.471511 N/A
CREATE_KEY,LIST_KEYS 10%,90% Leader read (baseline) 384.17 3,615.25 107.107106 57.610108
CREATE_KEY,LIST_KEYS 10%,90% Batching disabled 3,983.28 10.3685 4,074.35 1.1270 16.235464 103.484811
CREATE_KEY,LIST_KEYS 10%,90% Batching enabled 3,852.27 10.0275 4,210.29 1.1646 14.221871 83.369605
CREATE_KEY,LIST_KEYS 30%,70% Leader read (baseline) 1,048.83 3,386.85 100.985067 49.900742
CREATE_KEY,LIST_KEYS 30%,70% Batching disabled 8,608.64 8.2078 1,738.83 0.5134 7.452631 408.199677
CREATE_KEY,LIST_KEYS 30%,70% Batching enabled 8,747.88 8.3406 1,789.96 0.5285 11.018446 529.75776
CREATE_KEY,LIST_KEYS 90%,10% Leader read (baseline) 8,467.57 883.45 20.601753 14.697683
CREATE_KEY,LIST_KEYS 90%,10% Batching disabled 9,669.82 1.1420 442.50 0.5009 13.162005 412.046207
CREATE_KEY,LIST_KEYS 90%,10% Batching enabled 9,347.02 1.1039 558.77 0.6325 13.135697 127.401691
CREATE_KEY,LIST_KEYS 70%,30% Leader read (baseline) 5,538.96 2,119.40 46.01335 82.778703
CREATE_KEY,LIST_KEYS 70%,30% Batching disabled 9,234.24 1.6671 1,006.17 0.4747 11.691424 475.057008
CREATE_KEY,LIST_KEYS 70%,30% Batching enabled 9,007.03 1.6261 1,199.23 0.5658 13.978648 377.931547
LIST_KEYS Leader read (baseline) N/A N/A 3,467.72 N/A 74.094971
LIST_KEYS Batching disabled N/A N/A 5,115.04 1.4750 51.548571
LIST_KEYS Batching enabled N/A N/A 5,606.89 1.6169 49.47335

Evaluation

  • The read throughput ReadIndex batching is the same or improve on the linearizable follower read
    • Due to this, we can consider enabling ReadIndex batching by default
  • Leader write throughput is always higher when follower read is enabled
    • This is because there are less RW contention on the leader
  • Follower read vs Leader read throughput
    • Point query (READ_KEY): The follower read throughput is always lower than leader read
    • Range query (LIST_KEYS): The follower read throughput are higher than the leader read only for pure read or read-dominated workloads

What is the link to the Apache JIRA

https://issues.apache.org/jira/browse/RATIS-2524

How was this patch tested?

UT, IT.

@ivandika3 ivandika3 self-assigned this Nov 30, 2026

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant