View on GitHub


Raft Distributed Consensus Protocol in Java

Download this project as a .zip file Download this project as a tar.gz file


libraft is a Java library that implements the Raft distributed consensus protocol. It aims to be a correct, modular and understandable Raft implementation.


libraft provides:

And consists of 2 components:

  1. libraft-core
  2. libraft-agent


Contains an implementation of the Raft algorithm. It also defines interfaces for the components (such as timers, packet senders, storage, etc.) it needs to operate. These interfaces make very few assumptions and should be easy to implement using any number of technologies.

An architecture diagram is shown below. Interfaces are in italics and implementations in bold.

libraft-core Architecture Diagram


Typically the component most applications will interact with. It provides a:

  1. Reference implementation for the interfaces defined in libraft-core.
  2. Facade over libraft-core that can be instantiated to provide distributed consensus.

The relationship between the libraft-* components is shown below. Again, interfaces are in italics and implementations in bold.

libraft-agent Architecture Diagram


libraft also comes with a fully-implemented sample application in libraft-samples/kayvee. KayVee is a distributed key-value store that uses libraft-agent to replicate key-value pairs to a cluster. It demonstrates how to integrate libraft into a server to provide distributed consensus.

The relationship between KayVee servers, clients and libraft-agent is shown below.

KayVee Cluster Diagram

Getting libraft

libraft is available through Maven Central: add libraft-agent as a dependency.


dependencies {
    compile 'io.libraft:libraft-agent:0.1.1'




In addition to the project README, libraft comes with javadoc:

Component Latest Version
libraft-core 0.1.1
libraft-agent 0.1.1
kayvee 0.1.1

Getting in Touch

Please submit all code or documentation issues or feedback to Github Issues.

If you have other libraft or Raft questions, please post to the raft-dev mailing list.