imsinha
imsinha

Reputation: 51

Java implementation for consensus algorithm

I am working on a distributed systems and I have to implement consensus algorithm ( pref. Paxos ). I was looking for any API which I can use to have the consensus. But I could only stumble upon Apache Zookeeper who provides this facility. But I cannot use ZK as it fails when majority of the servers are down. This does not go along with my problem.Is there any other API or open source project which can help me to avoid the code the implementation from scratch?

Upvotes: 0

Views: 2782

Answers (1)

jop
jop

Reputation: 2316

You cannot solve consensus when a majority of servers is down, unless you have some way to tell with absolute certainty that they are indeed down, which is unlikely. ZooKeeper is thus correct, as it doesn't promise you the impossible.

Allow me to explain. Consider that you have 3 servers. One of them suspects that the remaining 2 have failed (e.g. missed some heartbeat) and proceeds to decide alone on the outcome of consensus. If the remaining 2 have not failed, they might decide differently, thus leading to inconsistency. This is safety violation, also known informally as the "split-brain" problem.

Note that even if you have a STONITH device, that allows servers to shutdown others, the previous situation might lead to everyone being shutdown, thus making the system unavailable as a whole. This a liveness violation.

Finally, if you have a really good STONITH device that never kills the last server standing, you don't need an algorithm to solve consensus. Just use the STONITH to try to kill everybody, and let the surviving server become the leader and decider. That STONITH is the consensus implementation.

So, stick with ZooKeeper.

Upvotes: 2

Related Questions