All Projects → s4ayub → huffleraft

s4ayub / huffleraft

Licence: MIT license
Replicated key-value store driven by the raft consensus protocol 🚵

Programming Languages

go
31211 projects - #10 most used programming language

Projects that are alternatives of or similar to huffleraft

6.824 2018
MIT 6.824 2018 lab. MIT6.824分布式系统(2018秋)
Stars: ✭ 59 (+84.38%)
Mutual labels:  distributed-systems, raft, raft-consensus-algorithm
Verdi Raft
An implementation of the Raft distributed consensus protocol, verified in Coq using the Verdi framework
Stars: ✭ 143 (+346.88%)
Mutual labels:  distributed-systems, key-value, raft
Etcd
Distributed reliable key-value store for the most critical data of a distributed system
Stars: ✭ 38,238 (+119393.75%)
Mutual labels:  distributed-systems, key-value, raft
Kites
🪁 A consistency, partition tolerance completed distributed KV store, implementation of the Raft distributed consensus protocol and Kotlin.
Stars: ✭ 41 (+28.13%)
Mutual labels:  distributed-systems, raft, raft-consensus-algorithm
Atomix
A reactive Java framework for building fault-tolerant distributed systems
Stars: ✭ 2,182 (+6718.75%)
Mutual labels:  distributed-systems, raft, raft-consensus-algorithm
Hraftd
A reference use of Hashicorp's Raft implementation
Stars: ✭ 732 (+2187.5%)
Mutual labels:  distributed-systems, key-value, raft
Leto
A key value storage example powered by hashicorp raft and BadgerDB
Stars: ✭ 73 (+128.13%)
Mutual labels:  raft, hashicorp, raft-consensus-algorithm
Elasticell
Elastic Key-Value Storage With Strong Consistency and Reliability
Stars: ✭ 453 (+1315.63%)
Mutual labels:  distributed-systems, key-value, raft
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.
Stars: ✭ 478 (+1393.75%)
Mutual labels:  distributed-systems, raft, raft-consensus-algorithm
Copycat
A novel implementation of the Raft consensus algorithm
Stars: ✭ 551 (+1621.88%)
Mutual labels:  distributed-systems, raft, raft-consensus-algorithm
Mit 6.824 2018
Solutions to mit 6.824 2018
Stars: ✭ 158 (+393.75%)
Mutual labels:  distributed-systems, raft, raft-consensus-algorithm
Rqlite
The lightweight, distributed relational database built on SQLite
Stars: ✭ 9,147 (+28484.38%)
Mutual labels:  distributed-systems, raft
little-raft
The lightest distributed consensus library. Run your own replicated state machine! ❤️
Stars: ✭ 316 (+887.5%)
Mutual labels:  distributed-systems, raft
Xraft
xnnyygn's raft implementation
Stars: ✭ 99 (+209.38%)
Mutual labels:  distributed-systems, raft
Raft Rs
Raft distributed consensus algorithm implemented in Rust.
Stars: ✭ 1,859 (+5709.38%)
Mutual labels:  distributed-systems, raft
Trek
Trek is a CLI/ncurses explorer for HashiCorp Nomad clusters.
Stars: ✭ 26 (-18.75%)
Mutual labels:  distributed-systems, hashicorp
Blog
my blog, using markdown
Stars: ✭ 25 (-21.87%)
Mutual labels:  distributed-systems, raft
Bifrost
Pure rust building block for distributed systems
Stars: ✭ 118 (+268.75%)
Mutual labels:  distributed-systems, raft
Zatt
Python implementation of the Raft algorithm for distributed consensus
Stars: ✭ 119 (+271.88%)
Mutual labels:  distributed-systems, raft
Mit6.824 distributedsystem
MIT6.824分布式系统(2018秋)
Stars: ✭ 135 (+321.88%)
Mutual labels:  distributed-systems, raft-consensus-algorithm

huffleraft

Replicated fault-tolerant key-value store driven by hashicorp/raft and dgraph-io/badger

Please read the example to see the system in action, especially for CRUD operations on a 5 node cluster!
For full documentation and more thorough descriptions: godoc

import "github.com/s4ayub/huffleraft"

Features and Purpose:

A RaftStore instance encapsulates a raft node (from hashicorp/raft) for consensus, a storage system (from dgraph-io/badger) for key-value pairs and an HTTP server to accept accept and redirect requests to the leader node.

The purpose of this package is to explore the raft consensus algorithm, specifically hashicorp's implementation. This package is effective for experimenting with raft because the API is such that the user doesn't even have to build any HTTP requests, rather, the package does that in the background through Get, Set, Delete, and Join. This makes it very easy and quick to play around with raft in conjunction with other code.

  • Perform CRUD operations on draph-io's Badger storage in a distributed manner
  • Fault tolerant as per the raft consensus algorithm
  • Commands can be performed on any node in a cluster and they'll be redirected to the leader of the cluster
  • Logs are truncated using the Snapshot, Restore and Persist mechanism provided by hashicorp/raft (checkout fsm.go)

Example logs:

Once a couple RaftStore instances are running, and a cluster is formed, the logs may look something like this after a Set command has been performed on them:

2017/09/04 04:02:07 [DEBUG] raft: Node 127.0.0.1:8740 updated peer set (2): [127.0.0.1:8730 127.0.0.1:8750 127.0.0.1:8740]
2017/09/04 04:02:07 [DEBUG] raft-net: 127.0.0.1:8730 accepted connection from: 127.0.0.1:62560
2017/09/04 04:02:07 [DEBUG] raft-net: 127.0.0.1:8740 accepted connection from: 127.0.0.1:62561
[raftStore | 127.0.0.1:8750]2017/09/04 04:02:11 key: yes, value: no, set

Motivation and References:

I wanted to dive deeper into distributed systems by building one of my own. The following repository was helpful in the development of huffleraft:

  • hraftd
    • This is a simple reference use of hashicorp/raft also made to study the implementation of the consensus algorithm. However, it required the user to interact with the system as a client and use curl to submit requests to the server. My package builds on top of this by being embeddable inside code, implementing command redirection to the leader node and by using dragph-io's badger as a faster storage compared to a native Go map. The people at hashicorp were very quick to answer any questions I had as well.

Design Decisions:

  • Leader re-direction:

    • The RaftStore struct encases an http listener to handle requests and a RaftServer to handle the consensus. There are two important addresses associated with each raft store. The httpAddr listens for http requests, and the raftAddr which the raft server uses for its transport layer between raft nodes. As per the consensus algorithm, commands such as setting, deleting and joining must be sent to the leader node only. The leader's raftAddr can easily be accessed in a cluster by raftServer.Leader() (raftServer being an instance of Raft from hashicorp/raft). However, the httpAddr associated cannot be easily retrieved, hence, a link must be made between the raftAddr and the httpAddr, since the httpAddr is the one that the user would be sending their commands to. I decided that the httpAddr would always be 1 port away from the raftAddr. The httpAddr for a RaftStore instance can always be retrieved now by adding 1 to its raftAddr.
  • Using dgraph-io/badger:

    • Bagder was proposed as a performant Go alternative to RocksDB which made it an attractive storage back-end for the key-value store.

Caveats and Suggested Improvements:

  • Cannot use side by side ports (8866 and 8867 for example) for two raft servers because the port next to the one on which a raft server is initiated on, is used for http requests. This is done to establish a link between the raftAddr and the httpAddr as discussed above. This routing system can likely be improved upon using a custom multiplexer setup where requests can be sent to the same port that the raft node exists on. Something like this in rqlite: https://github.com/rqlite/rqlite/tree/master/tcp
  • More robust error handling

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].