Skip to main content

Distributed Transactions: 2PC, Saga, Choreography vs Orchestration and Eventual Consistency

Learn Distributed Transactions: 2PC, Saga, Choreography vs Orchestration and Eventual Consistency (Phase 7 · Database and Transactions (Core), Microservices) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.

The problem and Two-Phase Commit (2PC) • With database per service a business operation (place order: reserve stock, charge payment, create shipment) spans several databases: no single ACID transaction . • 2PC : a coordinator asks all participants to prepare (lock and vote), then commit or abort . Provides atomicity (XA/JTA), but: blocking (locks held while waiting for the coordinator; a coordinator failure leaves participants stuck), latency , reduced availability (all must be up), and not supported by many brokers/NoSQL/SaaS. It also tightly couples services. Avoid 2PC in microservices ; use...

More lessons in Phase 7 · Database and Transactions (Core)