Why is two-phase commit (2PC) generally avoided in microservices, and what problems does it introduce?
Last updated
Two-phase commit (2PC) requires synchronous, blocking coordination with locks held from prepare to commit. This kills throughput and availability, since one slow service stalls everything.
The coordinator is a single point of failure (participants can be stuck in-doubt). All services must be up at once and support XA, which many stores and APIs don't.
The alternative is Sagas with local transactions, async events, and compensations, trading atomicity for availability and loose coupling.
- https://www.wecreateproblems.com/interview-questions/microservices-interview-questions
- https://dev.to/rpi1337/building-distributed-resilience-the-saga-pattern-for-financial-applications-51cf
- https://mentorcruise.com/questions/microservices/
- https://hosseinnejati.medium.com/the-two-phase-commit-problem-why-distributed-transactions-are-hard-80fd2f16aebf
- https://www.hiration.com/blog/microservices-interview-questions/
- https://stackoverflow.com/questions/65382918/2pc-distributed-transactions-across-many-microservices
- https://stackoverflow.com/questions/55249656/why-is-2-phase-commit-not-suitable-for-a-microservices-architecture
- https://www.geeksforgeeks.org/interview-prep/java-service-communication-data-management-resilience-interview-questions/