Comparing various methods of distributed transactions
In this section, we will look at three ways to handle consistency across a distributed system. The first will be the Two-Phase Commit (2PC), which can offer the strongest consistency but has some large drawbacks. The other two are the Choreographed Saga and the Orchestrated Saga, which still offer a good consistency model and are excellent options when 2PCs are not an option.
The 2PC
At the center of a 2PC is a coordinator that sends the Prepare and Commit messages to all the participants. During the Prepare phase, each participant may respond positively to signify they have started a local transaction and are ready to proceed. If all the participants have responded positively, then the coordinator will send a COMMIT
message to all of the participants and the distributed transaction will be complete. On the other hand, if any participant responds negatively during the Prepare phase, then the coordinator will send an ABORT
...