Giter VIP home page Giter VIP logo

distributed-consensus's Introduction

distribute-consensus

Distributed consensus algorithms implemented using Kafka messaging.

There are two consensus algorithms implemented here.

Leader Election

Leader election algorithm implemented here is an round based algorithm. A round (round number = n) in leader election contains the set of state transitions happen while electing a single leader and until the failure of the leader. After that leader is dead a new leader election round(round number = n+1) is started. The separation of rounds' records in the Kafka log is done using the round numbers. Kafka records with same round number are the state transitions happened in that round.

Testing Procedure

n = given value for leader candidate thread count. t = given time period (in seconds).

  • Tester Starts leader candidate threads until (n) threads have been started. (with random time waits between thread starts)
  • Randomly start/kill threads for t time maintaining at least n*0.8 number of threads and at most n*1.2 number of threads in the election.
  • Kill all the remaining threads to finish the test run after time t.

Usage

  1. Build Tester using mvn clean install

  2. Run Zookeeper.

  3. Run Kafka.

    • (You can follow this Kafka quick start to start a single node Zookeeper and Kafka services)
  4. Run the Jar giving location to save the log, Kafka server address, kafka topic, a number of leader candidate threads(n) to start and test run time(t).

    java -Dpath=<locatoin to save the log file> -jar <location to the jar built in 1.> < kafka server address> <kafka topic> <maximum leader candidate thread count> <test time t>

    ex: java -Dpath=/home/JohnDoe/test0.log -jar Tester.jar localhost:9092 election 50 60

Distributed Lock

Distributed Lock algorithm implemented here has no rounds. In distributed lock algorithm the entire kafka log contains events of same algorithm execution. Therefore no need of separating rounds in the Kafka log (Here, Kafka log can be considered as a single round).

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.