What is Raft?
Raft is a consensus algorithm designed to be easy to understand.
It gives the same kind of fault tolerance as Paxos for crash failures:
as long as a majority of nodes are alive, the cluster keeps
working.
Raft is not a blockchain algorithm. It is used in — Kubernetes
etcd, HashiCorp Consul, CockroachDB — to replicate configuration and
data inside your datacenter.
How Raft works
Leader election — one node becomes Leader; others are
Followers.
Log replication — client writes go to the Leader; Leader appends
to its log and copies to Followers.
Commit — once a majority has stored an entry, it is committed and
applied to the state machine.
Safety — if the Leader dies, a new election runs; committed
entries are never lost.
sequenceDiagram
participant Client
participant L as Leader (C)
participant F1 as Follower A
participant F2 as Follower B
participant F3 as Follower D
participant F4 as Follower E
Note over L,F4: 1. C wins election (3 of 5 votes)
Client->>L: SET config/key = "prod-v2"
L->>L: Append entry #42 to local log
L->>F1: AppendEntries #42
L->>F2: AppendEntries #42
L->>F3: AppendEntries #42
L->>F4: AppendEntries #42
F1-->>L: OK
F2-->>L: OK
F3-->>L: OK
Note over L: Majority (3/5) acked → commit #42
L-->>Client: Success