Consensus
Problem
Several machines maintain shared state.
Some can fail, messages can be delayed, and nodes can temporarily disagree.
They still need to agree on decisions such as:
Who is leader?
or:
Which value was committed?
Solution — Consensus Protocol
Protocols such as Raft coordinate nodes so they can agree on ordered decisions despite certain failures.
For example, five servers elect a leader, which records a change and copies it to the others. Once three servers have stored the new entry, the leader commits it and tells them to apply it. If the leader fails, voting rules select an up-to-date replacement and preserve committed entries. The cluster can keep progressing with two servers unavailable, provided the remaining three can communicate.
Core idea: consensus lets distributed nodes reach reliable agreement without assuming every node is always available.