Advertisement
varun1729

Untitled

Apr 18th, 2023
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.88 KB | None | 0 0
  1. Raft Consensus Algorithm
  2.  
  3. Refer this paper: [raft.pdf](https://github.com/VARUNvk1729/Raft-Consensus-Algorithm/files/11268629/raft.pdf)
  4.  
  5. This is a simple implementation of the Raft consensus algorithm in Python. The implementation covers the following tasks:
  6.  
  7. 1. Leader Election
  8. In this task, X number of nodes are set up, where each node initially starts as a follower with a random timer (between 1500-3000ms). When the timer expires, the node becomes a candidate and requests votes from all other nodes. If a candidate receives the majority of the votes, it becomes a leader and sends a heartbeat to all nodes. The paper provides detailed technical information.
  9.  
  10. 2. Append Entries
  11. Once a leader is elected, it can start servicing client requests. Each client request contains a command to be executed. The leader appends the command to its log as a new entry and then sends appendEntries in parallel to each of the other servers/nodes to replicate the log entry.
  12.  
  13. For this task, a client (such as Postman) calls the leader's /executeCommand, which adds the command to the log entry at that checkpoint. The leader then sends the log to all other nodes.
  14.  
  15. Example:
  16.  
  17. Let's say there are four nodes, and node 1 is the leader. When node 1 receives the executeCommand request from the client, it adds the command to the log entry and sends the log to all other nodes.
  18.  
  19. ![image](https://user-images.githubusercontent.com/76661061/232969338-c78349bc-40eb-45b8-a4c2-90a7f6500e70.png)
  20.  
  21.  
  22. TO DO:
  23.  
  24. 3. Node Recovery
  25. If a node crashes and then rejoins the network, it needs to catch up on the existing logs of the other nodes. In this task, you need to add logic where a new node catches up with the existing node's log entries.
  26.  
  27. Please refer to the paper for more details on the Raft consensus algorithm.
  28.  
  29. If you notice any grammatical errors, please feel free to correct them to make this README more readable.
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement