Raft
共识机制 raft
main idea is to allow a collection of machines to work as a group that can survive the failures fo some of its members.
leader election
- what: in each term, elect a leader. when time out, start a new election.
- why: one leader to recieve request and syn among all machines.
- how: begin one election with term++, every one vote itself first and request others, if it finds other have more latest term, it will become follower.
log replication
- what: append command as a log entry.
- why: make sure everyone has same log
- how: commit, if consistence, duplicate leader's
- When AppendEntries consistency check fails, decrement nextIndex and try again
- When follower overwrites inconsistent entry, it deletes all subsequent entries