Eugene To
Eugene To

Reputation: 1938

Consensus algorithm for two nodes

As I know PAXOS, RAFT, and ZAB can work with two nodes if they are both active. It means that if one of two nodes crashes the distributed application will crash too. Fix me if I am wrong, please.

Is there any algorithm that is suitable for two-nodes cluster and that will tolerate the failure of one node?

Upvotes: 2

Views: 1573

Answers (1)

kuujo
kuujo

Reputation: 8185

There is no consensus algorithm that can tolerate the failure of a majority of the cluster. The problem is that by its definition consensus requires input from a majority of the cluster. How can one achieve consensus if you can't even communicate with a majority of the servers? How does one know the servers that are down would agree on any given value? Majority based consensus algorithms work under the assumption that a majority agreement on some value enforces the requirement that no other value can be chosen for a given state.

Of course, in a general sense there are a number of algorithms that will tolerate the failure of one node in a two node system. The question is whether you are willing to tolerate the trade-offs. This largely depends on your use case. Consensus algorithms provide strong consistency at the expense of availability. Alternatively, if you need availability (i.e. a cluster that continues to operate even with less than a majority of the nodes alive) there are significantly simpler algorithms you can use such as consistent hashing and gossip. Again, these simply depend on your use case.

Upvotes: 4

Related Questions