Two Phase Commit

A pattern to implement distributed transaction. Which involves 2 phase

  1. Prepare phase:
    • Coordinator asks the participants to whether or not they're ready to commit.
    • They return yes or no
  2. Commit phase:
    • If all the participants say yes, we commit
    • If one participants say no, we ask all the participants to rollback

Pasted image 20230920124044.png

What happen if our services keep failing?

We can store the status in the coordinator of the failing task and investigate.

Applications

  1. Cross multiple database commits
  2. Simple and fast service