The Saga Pattern for Distributed Transactions
Coordinate data consistency across multiple microservices without a global transaction by using the saga pattern with compensating actions.
Why Distributed Transactions Are Hard
In a monolith one database transaction can update everything atomically. With microservices each service owns its own database, so a single ACID transaction across them is not possible.
Introducing Sagas
A saga is a sequence of local transactions, one per service. Each step publishes an event that triggers the next. If a step fails, earlier steps are undone with compensating actions.
All lessons in this course
- Decomposing Monoliths
- Message Queues & Events
- Service Discovery & Communication
- The Saga Pattern for Distributed Transactions