Skip to content

5.1. Distributed Transactions

A transaction that spans services cannot rely on a single database’s ACID guarantees, so you must rebuild atomicity from parts that can each fail independently. Two-phase commit gives you atomicity but blocks when the coordinator dies; sagas give you availability but force you to design compensating actions for every step. This chapter covers that trade-off in depth, along with the outbox pattern that solves the deceptively hard problem of writing to a database and publishing a message atomically.