liveBook · Manning

Consensus

As explained in The Coder Cafe

A consensus algorithm enables distributed nodes to agree on a common value or decision despite failures or communication delays.

Consensus is the problem of getting distributed nodes to agree on a value or decision despite failures or network partitions. It matters when no single node controls the whole database: a transaction that commits across nodes requires them to agree on what happened. section 6.6 section 6.5

Two writes, one decision

Suppose one node receives a request to set foo=42 while another receives a request to set foo=200. Without agreement, the nodes could return different values. Consensus is how they settle on one outcome rather than each treating its own write as authoritative. section 6.6

A consensus algorithm must provide three properties:

  • Termination: the decision process does not remain stuck forever. section 6.6
  • Integrity: a node does not change its decision after reaching it. section 6.6
  • Agreement: nodes reach the same outcome. section 6.6

Consensus supports strong consistency, leader election, reliable replication, and recovery after failures. Its guarantees involve both safety—not deciding conflicting values—and liveness—eventually reaching a decision. Network partitions make these promises costly: consistency and availability cannot both be guaranteed during a partition. Paxos and Raft are two named consensus algorithms. section 6.6 section 6.15

How The Coder Cafe covers it

How deep it goes
Defines agreement, termination, integrity, safety, and liveness, but does not detail Paxos or Raft steps in the supplied evidence.
Examples
Contrasts simultaneous requests to set the same key to 42 and 200 on different nodes.
What it assumes
Builds on distributed transactions and safety and liveness while defining consensus rather than assuming prior knowledge of it.
What you can do after
Evaluate/understand it to recognize why nodes need agreement and distinguish a shared decision from conflicting outcomes.
How it connects
Connects distributed transactions and strong consistency to leader election, replication, safety, liveness, and network partitions.

Also explained in

Compare how 5 books explain consensus →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of The Coder Cafe. The section links point to the parts of the book it draws on.