Paxos vs two phase commit

13,934

Solution 1

2PC blocks if the transaction manager fails, requiring human intervention to restart. 3PC algorithms (there are several such algorithms) try to fix 2PC by electing a new transaction manager when the original manager fails.

Paxos does not block as long as a majority of processes (managers) are correct. Paxos actually solves the more general problem of consensus, hence, it can be used to implement transaction commit as well. In comparison to 2PC it requires more messages, but it is resilient to manager failures. In comparison to most 3PC algorithms, Paxos renders a simpler, more efficient algorithm (minimal message delay), and has been proved to be correct.

Gray and Lamport compare 2PC and Paxos in an excellent paper titled "Consensus on Transaction Commit".

(In the answer of peter, I think he is mixing 2PC with 2PL (two-phase locking).)

Solution 2

2-PC is the most traditional transaction commit protocol and powers the core of atomicity of transactions. But it is blocking in nature, i.e. if the transaction manager/coordinator fails in between, it will cause the protocol to block and no process will be aware of it. It requires manual intervention to repair the coordinator.

While Paxos being a distributed consensus protocol has multiple such coordinators and if a majority of the coordinators agree to the transaction completion, it becomes a successful atomic transaction.

You should read https://www.microsoft.com/en-us/research/wp-content/uploads/2016/02/tr-2003-96.pdf to understand how these two protocols are differentiated in a more granular manner. In the same paper, Gray and Lamport also introduce a protocol i.e. a combination of Paxos and 2-PC for faster performance.

Share:
13,934
Keeto
Author by

Keeto

Updated on June 21, 2022

Comments

  • Keeto
    Keeto about 2 years

    I am trying to understand the difference between paxos and two phase commit as means to reach consensus among multiple machines. Two phase commit and three phase commit is very easy to understand. It also seems that 3PC solves the failure problem that would block in 2PC. So I don't really understand what Paxos is solving. Can anyone illuminate me about what problem does Paxos exactly solve?

  • Artem
    Artem almost 8 years
    And then three is Raft which is a more light-weight version of Paxos. There are a lot of open-source systems using raft right now. Such as Etcd, Consul, Cockroachdb, etc.
  • simbo1905
    simbo1905 over 5 years
    Multi-Paxos in steady state (no failures) has the minimum number of message to support continuing to work with f failures. In a 3 node cluster the leader only needs one round trip to know the data is at a second node it doesn't need to wait for the third nodes response. 2PC also need to exchange a message with another node requiring one round trip. Both algos can piggyback the commit message on the next value message. So I don't think that is is accurate to say that Paxos requires more messages as performance is equivalent in steady state.