Why is two-phase commit (2PC) problematic in microservices?

Answer

Two-phase commit (2PC) is a distributed transaction protocol that coordinates multiple participants to either all commit or all rollback a transaction. It requires a coordinator that first sends a "prepare" request to all participants (phase 1) and then, if all agree, a "commit" (phase 2). In microservices, 2PC is problematic for several reasons: it creates tight coupling between services and the coordinator, it is blocking — participants hold locks during the protocol, reducing throughput significantly, the coordinator is a single point of failure, and it does not work across heterogeneous databases (SQL + NoSQL). The recommended alternative is the Saga pattern with compensating transactions, which achieves eventual consistency without distributed locking.