Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimization: Cache replicated entries for faster lookup for applying to state machine. #12

Closed
2 tasks done
thedodd opened this issue Aug 19, 2019 · 4 comments · Fixed by #88
Closed
2 tasks done
Labels
enhancement New feature or request good first issue Good for newcomers optimization An optimization to the system replication Related to the replication system

Comments

@thedodd
Copy link
Collaborator

thedodd commented Aug 19, 2019

todo

  • Update the append entries algorithm for followers so that recent entries are buffered up to a specific threshold so that the process of applying logs to the state machine will not need to fetch those logs from storage a majority of the time.
  • Update the append entries handler so that the process of applying logs to the state machine is no longer directly involved. Right now, applying logs to the state machine is conditionally called when it becomes safe to do so. This needs to be moved to be its own async task.
@thedodd thedodd added optimization An optimization to the system replication Related to the replication system enhancement New feature or request labels Aug 19, 2019
@thedodd thedodd added the good first issue Good for newcomers label Aug 18, 2020
@MarinPostma
Copy link
Contributor

I am currently working on this

@thedodd
Copy link
Collaborator Author

thedodd commented Oct 20, 2020

@MarinPostma awesome! Keep me posted. I am definitely of the opinion that we should use an async task to handle this responsibility. It can be owned by the RaftCore instance variants as needed. Happy to chat about implementation and design any time!

@thedodd
Copy link
Collaborator Author

thedodd commented Nov 18, 2020

I'm now hacking on this as I am blocked until its done, so it should be done quite soon :).

@thedodd
Copy link
Collaborator Author

thedodd commented Nov 19, 2020

Done. About to push/open PR. Hopefully will have a release out very soon. No API changes, so this will be a bug fix release.

thedodd added a commit that referenced this issue Nov 19, 2020
With this change, we are also caching entries which come from the leader
replication protocol. As entries come in, we append them to the log and
then cache the entry. When it is safe to apply entries to the state
machine, we will take them directly from the in-memory cache instead of
going to disk.

Moreover, and most importantly, we are not longer blocking the
AppendEntries RPC handler with the logic of the state machine
replication workflow. There is a small amount of async task juggling to
ensure that we don't run into situations where we would have two writers
attempting to write to the state machine at the same time. This is
easily avoided in our algorithm.

closes #12
closes #76
thedodd added a commit that referenced this issue Nov 20, 2020
With this change, we are also caching entries which come from the leader
replication protocol. As entries come in, we append them to the log and
then cache the entry. When it is safe to apply entries to the state
machine, we will take them directly from the in-memory cache instead of
going to disk.

Moreover, and most importantly, we are not longer blocking the
AppendEntries RPC handler with the logic of the state machine
replication workflow. There is a small amount of async task juggling to
ensure that we don't run into situations where we would have two writers
attempting to write to the state machine at the same time. This is
easily avoided in our algorithm.

closes #12
closes #76
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers optimization An optimization to the system replication Related to the replication system
Projects
None yet
2 participants