Git Product home page Git Product logo

quintet's Introduction

quintet

An implementation of the Raft consensus protocol.

Feature

  1. Raft is a consensus algorithm for managing a replicated log, which means keeping the contents consistent on each server of a cluster by synchronizing the operations between each server.
  2. Quintet is very suitable for preventing single point of failure for some large distributed system like GFS. By slightly modifying the code of the single point, and running it on a cluster of several servers, as long as more than half of the cluster are still working, the content, no matter it stores in disk or memory, in each server would maintain consistent and correct.
  3. In our implementation, we provide a library with a few interfaces and hide almost all of the details in the background, so that the usage would be quite easy.
  4. Equipped by C++, boost and grpc, quintet is relatively efficient. And quintet can output pretty logs for debugging.

Usage

There are many situation suitable for this implementation.

  1. GFS (Google File System) : In GFS, there is a single server, called master, storing the meta data for the whole distributed system and responding to all of the request from the cluster. The backup of the master will be very important for the system, and this is where quintet comes in.
  2. DLM (Distributed Lock Manager): In many distributed system sharing resources, a distributed lock manager runs in every machine in a cluster, with a identical copy of cluster-wide lock. And the quintet can help the designer of DLM to keep locks on each server consistent.
  3. Distributed Chat Room: In our example, we implement a distributed chat room, in which the users holds the service of the chat room by themselves, and no external server is needed.

Get started

Prerequest

How to use

Include the Interface.h header file into the source code, and assume the operations you want to synchronize among the servers are some functions:

    int foo(int a);
    void addEntry(string s, int b);

The following are the steps to do:

  1. Declare a interface
        quintet::Interface interface;
  2. Bind the operating functions to the interface at the begining of the code
        interface.bind("foo", [](int a) -> int {...});
        interface.bind("addEntry", [](string s, int b) -> void {...});
  3. Now whenever you want to call the operating function, you wish to execute on every server, use the call function:
        interface.call("foo", 15);   // 15 is the arguement for the foo function
        interface.call("addEntry", std::string("hello, world"), 2);
  4. Everything will be taken care of by the quintet library, and you can now write the code as you want.

On each server, start the same code (or you can customize the operating function on each server and do something interesting), with different config file, the whole system will work properly. A specific example can be found in chatRoom.cpp. With a really brief code, a distributed chat room is built.

quintet's People

Contributors

engineev avatar hzfengsy avatar michaelvll avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  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.