Consistency and Consensus

214 阅读1分钟
  1. Fault-Tolerant Consensus  

Uniform agreement:No two nodes decide differently.

Integrity:No node decides twice.

Validity:If a node decides value v, then v was proposed by some node.

Termination:Every node that does not crash eventually decides some value.  (fault tolerance)

ps:  there are no Byzantine faults

2. Consensus algorithms and total order broadcast 

The best-known fault-tolerant consensus algorithms are Viewstamped Replication (VSR) , Paxos , Raft , and Zab.

total order broadcast  have these propery: messages to be delivered exactly once(integrity ),in the same order to all nodes(agreement ),messages are not lost (Termination).

single-leader replication is a good solution for fault-tolerant total order broadcast. these consensus algorithms don’t guarantee that the leader is unique, the algorithms define an epoch number (eg, term number in Raft) and guarantee that within each epoch, the leader is unique. 

Consensus systems always require a strict majority to operate. This means you need a minimum of three nodes in order to tolerate one failure (the remaining two out of three form a majority), or a minimum of five nodes to tolerate two failures (the remaining three out of five form a majority).

 Consensus algorithms  Limitations: 

1.  compared with databases , it is designed for small data (eg. configuration) and quite slow-changing. 

2. frequent leader elections result in terrible performance because the system can end up spend‐ ing more time choosing a leader than doing any useful work.

3. sensitive to network problems

 3. ZooKeeper  features:

1. total order broadcast

2. Linearizable atomic operations,eg lock

3. Failure detection:ephemeral nodes based on heartbeats 

4. Change notifications :client joins the cluster or fails

5. node is live or fail. due to unbounded network delays it’s not possible to reliably detect whether another node has failed. However, if you couple failure detection with consensus, nodes can come to an agreement about which nodes should be considered alive or not.