Hashicorp provide a nice implementation of the Raft consensus protocol, and it’s at the heart of InfluxDB (amongst other systems). I wanted to experiment with a simple system built using this particular Raft implementation, so was inspired by raftd to built hraftd.

A distributed key-value store

hraftd is a simple key-value store, allowing you read and write key-value pairs. It can tolerate node failures and network partitions, demonstrating the nature of a distributed system.

The topology of a 3-node cluster is shown below. The 3 Raft nodes (shown in blue) communicate over persistent TCP links, and form the cluster. Over these links travel log entries and heartbeats. Accesses — both read and write — to the key-value store take place via HTTP requests from an external client (shown in orange) to the leader.

(Credit to Martin Kleppmann for inspiring this style of graphics.)

By working with a very simple Raft-based system, it’s much easier to study the Raft algorithm in general, as well as understand Hashicorp’s implementation in particular.

Downloading the source

You can check out hraftd on github.