The cost of two phase commit
A classic distributed transaction uses two phase commit. A coordinator asks every participant to prepare, then tells them all to commit. It gives strong atomicity but has serious weaknesses.
- It is blocking. If the coordinator crashes after prepare, participants hold locks and wait, unable to decide alone.
- It couples availability. One slow participant stalls the whole transaction.
- It scales poorly because every node must coordinate synchronously.
Alternatives that trade atomicity for availability
- Sagas split work into local steps with compensations, giving eventual business consistency.
- The outbox pattern writes a record and an event in one local transaction, then publishes the event reliably, avoiding cross service commits.
- Idempotent receivers let producers retry freely while consumers deduplicate.
These patterns accept temporary inconsistency in exchange for availability and partition tolerance, the practical tradeoff most large systems make.
Key idea
Two phase commit gives atomicity but blocks under failure, so large systems prefer sagas, outbox events, and idempotent receivers for availability.