Git Product home page Git Product logo

raftcore's People

Contributors

guille avatar kasperk81 avatar smeddows avatar

Stargazers

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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

raftcore's Issues

APIRaftConnector > requestvote & appendentries API endpoints

Hi,

First, thanks a lot for this work.
I am playing with RaftCore and IAPIRaftConnector.

My goal is to host the cluster (+ 1 node) and the API in a ConsoleApp in .NET 6 using OWIN.

Perhaps I am missing something but I can't find the requestvote & appendentries API endpoints.

APIRaftConnector.cs

private async Task<string> SendRequestVote(int term, uint candidateId, int lastLogIndex, int lastLogTerm) {
{
  ...
  var response = await client.PostAsync(baseURL + "requestvote", content); // <=== requestvote
  ...
}

private async Task<string> SendAppendEntries(int term, uint leaderId, int prevLogIndex, int prevLogTerm, List<LogEntry> entries, int leaderCommit)
{
  ...
  var response = await client.PostAsync(baseURL + "appendentries", content); // <=== appendentries
  ...
}

NodesController.cs

[HttpGet("[controller]")]
public IEnumerable<IEnumerable<string>> GetNodesInfo() {
  ...
}

// GET /nodes/log/:elems
[HttpGet("[controller]/log/{elems}")]
public JsonResult GetLogs(int elems) {
  ...
}

// GET /nodes/sm
[HttpGet("[controller]/sm")]
public IEnumerable<string> GetStateMachines() {
  ...
}

// PATCH /nodes
[HttpPatch("[controller]/{id}")]
public string SwitchState(int id) {
  ...
}

// POST /nodes/requests
[HttpPost("[controller]/requests")]
public string MakeRequest() {
  ...
}

Where is my mistake?
Thanks.

Log compaction

After a long time of execution, a replicated Raft node can get massive. The algorithm designers developed a protocol to compact the logs to reduce the space necessary to store and replicate the log data structure.

You can learn more about this feature reading the Raft paper §7

Improve APIRaftConnector

  • Test the class APIRaftConnector located inside RaftCore/Connections/Implementations/. Make sure it works properly.

  • Make the endpoints configurable.

Thread Safety

Don't know if you are still working on this, but I looked at your implementation and found some issues - just a FYI.

A lot of the operations in your implementation are not thread safe.

An example of this is, your heartbeats interval can exceed the time it takes to complete a heartbeat, as a result you can have two "AppendEntries" running concurrently, this causes issues particularly when both threads reach

toApply.ForEach(x => StateMachine.Apply(x.Command));

applying your logs twice.

You should have dedicated threads that loop this check and log application.

Membership changes

One of the most interesting parts about the Raft algorithm is the ability to swap between cluster configurations and sizes. The algorithm offers a protocol to do so safely without losing any data or any of the guarantees it provides. The functionality would allow the administrators of the clusters to replace, add or remove machines from a cluster without having to restart it.

You can learn more about this feature reading the Raft paper §6

Add more connectors and state machine implementations

The product developed ships with two basic state machine implementations and two basic
connectors.

More state machines could be added to cover more complicated use cases (for example, a state machine that executes entries on a PostgreSQL database).

The same could be done for connectors, supporting configurable APIs instead of a pre-fixed one, or
supporting SOAP services, for example.

Add persistent state support

Although the designed implementation can withstand network connectivity issues, it does not offer full support for more severe circumstances, such as application crashes or power outages.

The main solution of this problem is considered in the Raft algorithm paper, and consists of persisting some of the node’s state. This would require adding a protocol to both serialize part of the node’s state and reload this configuration after node crashes. In the developed implementation, all state is volatile.

Add vote codition

in RequestVote method,should we compare with term > CurrentTerm and vote true?

if(term>CurrentTerm)
 voteGranted = true;

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.