eBay / NuRaft

C++ implementation of Raft core logic as a replication library
Apache License 2.0
993 stars 235 forks source link

Does nuraft support linearizable read if generating no raft log entry of read requests? #475

Closed Brokenice0415 closed 10 months ago

Brokenice0415 commented 10 months ago

Serving every read request as a write one is unacceptable for the cost.

Does nuraft offer any way to support linearizable read, like ReadIndex or LeaderLease?

I have seen a similar issue #288, but it seems that the linearizable read in this issue still needs to generate raft log entries of read requests.

greensky00 commented 10 months ago

You can refer to the original Raft paper, section 8 Client interaction. To achieve linearizable read, you must always read the data from the leader. No need to append log for read, as described in the paper.

NuRaft provides an option to avoid overlapping time window between old leader and new leader, by having leadership expiration. That guarantees, if the current leader is alive and valid, its data is always fresh and there is no newer leader.

Brokenice0415 commented 10 months ago

Hi @greensky00 , thanks for your explanation! I have read the section in detail and understood how nuraft ensures the linearizable read better!