Abstract


3 States for a Node


Follower Node

  • All Nodes start in the Follower Nodes state

Leader Node

  • All changes from Client to the raft cluster go through the Leader Node

Candidate Node

2 Main Concepts


Leader Election

Log Replication

Log Replication is how a change is made using Append Entries

  1. Each change is added as a entry in the Leader Node’s log
  2. Log entry is currently uncommitted, so it doesn’t update the Leader Nodes’s state
  3. To commit the entry, the Leader Nodes first replicates it to the Follower Node via Append Entries
  4. Leader Nodes waits until a majority of nodes have written the entry
  5. Entry then committed on Leader Nodes, state updated
  6. A response then sent back to Client
  7. Leader then notifies the Follower Nodes that the entry is committed
  8. The Follower Nodes committed the entries, state updated
  9. Cluster now come to Distributed Consensus about the system state

Terminologies


Heartbeat Timeout

  • WIP

Election Timeout

Append Entries

Split Vote

Election Term

Actions taken by Candidate Node

  1. Vote for itself
  2. Sends out Request Votes messages to other nodes
  3. If the receiving node hasn’t voted yet in this Election Term then it votes for the new Candidate Nodes & reset its Election Timeout
  4. Once a Candidate Nodes has a majority of votes, it becomes Leader Node guarantees only one leader can be elected per term (Exception: Split Vote)
  5. The new Leader Nodes sending out Append Entries messages to its Follower Node
  6. Follower Nodes then respond to each Append Entries messages
  7. The Election Term will continue until a Follower Nodes stops receiving Append Entries & becoming a new Candidate Nodes (Election Timeout)

References