The Problem with Two-Phase Commit (2PC)
Traditional distributed transactions use 2PC (Prepare and Commit phases). 2PC is a blocking protocol: if the coordinator crashes during the commit phase, all participating service databases hold locks indefinitely, destroying system availability.
The Saga Pattern
A Saga breaks a distributed transaction across microservices into a sequence of local transactions. Each step updates its local database and publishes an event. If a subsequent step fails, the Saga executes compensating transactions backwards to undo changes.
Orchestration vs Choreography
Choreography: Services react to each other's domain events with no central controller (decoupled, but complex to trace). Orchestration: A central orchestrator state machine (e.g. Temporal, AWS Step Functions) explicitly commands each service and handles rollbacks.