← Back to microservices patterns mapconsistency
🔒
Microservices Pattern
Two-Phase Commit (2PC)
A coordinator asks participants to prepare, then commits or rolls back all participants.
Detailed Description
2PC provides atomicity but fights the autonomy and availability goals of microservices.
Most microservice systems prefer sagas, outbox, idempotency, and compensation instead.
Visual Diagram
Phase 1: prepare all All yes -> commit all Any no -> rollback all
Tradeoffs
Pros
True atomicity across resources
Cons
Blocking, coordinator SPOF, poor scalability
Examples: XA transactions; rarely preferred in microservices