Giter Club home page Giter Club logo

raft's Introduction

raft

Table of Contents

Introduction

This repository contains an educational implementation of the Raft Consensus Algorithm in Go.

Features

Feature Implemented
Log Replication Yes
Leader Election Yes
Persistence Yes
Membership Changes No
Log Compaction No

Run

  • Format:
go run kv/bin/main.go --id {node server id} --kvaddr {key-value server address}
  • Example, running all the nodes listed in the configuration file config.go:

Process#0

go run kv/bin/main.go --id 0 --kvaddr localhost:27004

Process#1

go run kv/bin/main.go --id 1 --kvaddr localhost:27005

Process#2

go run kv/bin/main.go --id 2 --kvaddr localhost:27006

Client

curl http://localhost:27006/set?key=a&val=b
> set value

curl http://localhost:27006/get?key=a
> b

Structure

key-value and raft servers are running under the same process

  • server.go - main part
  • Makefile - compiles proto
  • kv/bin/state#{id}.json - persistent state of a node with id {id} (generated after running main.go)
  • kv/bin/main.go - starts raft and key-value API servers
  • config.go - config of the raft cluster in the following way:
var Cluster = []ServerConfig{  
    {Id: 0, Address: "localhost:8080"}, 
}
  • time.go - all raft time constants multiplied by slow coefficient in the following way:
const (  
    slowCoeff = 10  
    DefaultElectionTimeout = slowCoeff * 150 * time.Millisecond  
    ...
)
  • Require further validation to ensure the implementation's correctness

raft's People

Contributors

njrslv avatar

Watchers

 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.