Giter VIP home page Giter VIP logo

goraft's Introduction

goraft

A minimal implementation of Raft in Go. Demo video.

This blog post walks through the code.

NOT FOR PRODUCTION USE.

Things that are missing:

  • Client serial identifier for each message (maybe the most obvious missing function/actual bug)
  • Snapshotting/checkpointing and associated state transfer
  • Configuration change protocol
  • Rigged up to Jepsen
  • Surely much else

Stress

Not particularly aggressive yet but does basic correctness and stress testing.

Read more about the details of what it tests in the README.

$ cd cmd/stress
$ go run main.go util.go

With the go-deadlock package turned off and the default sync package on, I get throughput of around 20k-40k entries/second with this stress test.

Distributed Key-Value Store API

Try out the builtin distributed key-value API.

$ cd cmd/kvapi && go build
$ rm *.dat

Terminal 1

$ ./kvapi --node 1 --http :2021 --cluster "0,:3030;1,:3031;2,:3032"

Terminal 2

$ ./kvapi --node 1 --http :2021 --cluster "0,:3030;1,:3031;2,:3032"

Terminal 3

$ ./kvapi --node 2 --http :2021 --cluster "0,:3030;1,:3031;2,:3032"

Terminal 4

Remember that requests will go through the leader (except for if we turn that off in the /get request). So you'll have to try sending a message to each server until you find the leader.

To set a key:

$ curl http://localhost:2020/set?key=y&value=hello

To get a key:

$ curl http://localhost:2020/get\?key\=y

References

And useful implementations I looked at for inspiration and clarity.

  • Hashicorp's Raft implementation in Go: Although it's often quite complicated to learn from since it actually is intended for production.
  • Eli Bendersky's Raft implementation in Go: Although it gets confusing because it uses negative numbers for terms whereas the paper does not.
  • Jing Yang's Raft implementation in Rust.

goraft's People

Contributors

eatonphil avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.