liveBook · Manning

Transaction coordinator

As explained in Microservices Patterns, Second Edition

A component that coordinates transaction participants and directs them to commit or roll back as a unit.

A transaction coordinator directs distributed transaction participants to commit or roll back as a unit. In XA two-phase commit, participants first prepare their changes and vote while holding required locks; the coordinator then instructs them to commit or roll back based on the votes. section 9.1.2

Distributed coordination has practical constraints:

  • XA transactions restrict technology choices because many modern databases and message brokers do not support them. section 9.1.2
  • Synchronous interprocess communication can reduce availability, making distributed transactions a poor fit for many microservice architectures. section 9.1.2

Order and customer services

An Order Service initiates the global transaction; a Customer Service registers as a participant, and both services enlist their databases. The coordinator collects their prepare votes before directing the outcome. section 9.1.2

Figure 9.1 A hypothetical implementation of XA/2PC in a microservice architecture. The services register as participants with the Transaction Coordinator. They enlist their databases in the distributed transaction. The Transaction Coordinator commits the transaction in two phases. In the prepare phases, participants vote on whether they can commit. In the commit phase, the transaction coordinator instructs all participants to either commit or roll back based on the collected votes.
microservices 2pc

Shows service registration, database enlistment, participant votes, and the coordinator's commit or rollback instructions. section 9.1.2

How Microservices Patterns, Second Edition covers it

How deep it goes
Explains prepare votes and commit instructions, then outlines technology, deployment, and availability constraints.
Examples
Illustrates coordination with Order and Customer services and their enlisted databases.
What you can do after
Understand how the coordinator uses participant votes to direct a distributed transaction's outcome.
How it connects
Connects XA, two-phase commit, ACID transactions, and microservices.

Also explained in

Compare how 3 books explain transaction coordinator →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Microservices Patterns, Second Edition. The section links point to the parts of the book it draws on.