Skip to content

alexpovel/miniraft

Repository files navigation

miniraft

An implementation of the Raft distributed consensus protocol for powering a key-value workload (read, write, CAS).

  • dependency-free, stdlib-only Rust (cold, release compile in ~1s)
  • Raft implementation passes Jepsen Maelstrom chaos testing, for the linearizable KV workload (the failures in the graph are expected, it is Jepsen probing for linearizability)
    • fully generic (literally and design-wise) core Raft: applicable to any workload backable by Raft; the core just holds opaque commands in its log, with an abstract state machine dependency-injected for committing into
    • channel-based glue layer to translate between KV RPCs and Raft core; enables pluggable I/O
    • focus on correctness: illegal states made unrepresentable levering the type system where feasible, and liberal use of asserts for pre/post conditions. No unsafe, no shenanigans

Not in the box

  • TCP/HTTP: I/O and the binary are specific to Jepsen Maelstrom, but that's just a couple hundred lines

  • async: stdlib-only, so threading is used.

    This is implemented asynchronously and non-blocking all the same: client and Raft RPCs can be emitted and received at any time. Awaiting responses to emitted RPCs is asynchronous as well, though messages go into single-receiver queues. That serializes requets, but the necessary mutual exclusion on the core Raft state does so anyway (there is only one lock, which incidentally makes deadlock-freedom much simpler to guarantee!)

  • live cluster configuration changes

About

Raft consensus algorithm implementation for a key-value store. Dependency-free, stdlib only. Passes Jepsen Maelstrom chaos testing

Topics

Resources

Stars

Watchers

Forks

Contributors