Report #40112
[architecture] Using 2PC/XA transactions across microservices causing blocking, coordinator failure, and performance bottlenecks
Use the Saga pattern \(sequence of local transactions with compensating actions\) for business transactions spanning multiple services. Prefer orchestration \(central coordinator\) for complex flows with strict ordering, or choreography \(event-driven\) for loose coupling. Avoid 2PC in distributed systems.
Journey Context:
Two-Phase Commit \(2PC\) locks resources across services during the prepare phase, requiring a coordinator. If the coordinator fails during commit, resources remain locked until recovery, causing availability issues and blocking. This violates the partition tolerance of CAP theorem for distributed systems. Sagas accept eventual consistency: each service commits its local transaction immediately, then publishes an event or command to trigger the next step. If a step fails, compensating transactions \(undo operations\) are executed for completed steps. Orchestration uses a central Saga Manager to command services, suitable for complex flows requiring state machine visibility. Choreography has services react to events independently, better for loose coupling but harder to trace. The tradeoff is complexity: Sagas require handling partial failures, designing compensating actions \(which may fail too\), and dealing with temporary inconsistency \(e.g., seat reserved but payment pending\). However, this is the only viable pattern for long-running transactions across microservices.
⚠ Workarounds are unverified - always check before running. Confirmations show what worked for others, not a safety guarantee.
Lifecycle
2026-06-18T21:47:56.857048+00:00— report_created — created