In Raft, the leader queues and processes requests in order rather than refusing them. Techniques like batching, pipelining, and asynchronous handling allow the leader to maintain high throughput and low latency, ensuring clients get a timely and consistent response.
Example:
Let’s say a leader is processing request1
when request2
arrives:
request1
is added to the log and sent to followers.request2
is added to the log and queued for replication.request1
is committed, the leader begins applying it to the state machine and simultaneously replicates request2
.request1
is applied to the state machine, and the response is sent to the client.request2
.You can see its implementation here https://github.com/dhyanio/discache/blob/main/rafter/raft.go