rabbitmq / ra

A Raft implementation for Erlang and Elixir that strives to be efficient and make it easier to use multiple Raft clusters in a single system.
Other
813 stars 96 forks source link

Refactor reading from log to reduce peak memory use #304

Closed kjnilsson closed 2 years ago

kjnilsson commented 2 years ago

Instead of reading batches into memory then processing we now process each entry as it is read from the log by introducing a new ra_log:fold/5 function. This function replaces all prior uses of ra_log:take which has been removed.

This substantially reduces peak memory use during recovery when, e.g. a quorum queue has a long backlog of largish messages. As a consequence of this recovery takes less time and thus has a positive availability property.

I tested this with a few clustered workloads and could not detect any noticeable performance regressions elsewhere.