What is the Saga pattern in microservices?
Answer
The Saga pattern manages long-running distributed transactions across multiple microservices without using a two-phase commit. A saga is a sequence of local transactions, each updating one service's database and publishing an event or message to trigger the next step. If any step fails, the saga executes compensating transactions to undo the completed steps. There are two coordination styles: Choreography, where each service reacts to events and publishes new events with no central coordinator (simpler but harder to observe), and Orchestration, where a central saga orchestrator explicitly commands each participant and handles failure logic (more visible and easier to debug). Sagas are essential for order checkout flows, booking systems, and any multi-service business transaction.
Previous
What is event-driven architecture and how does it apply to microservices?
Next
What is CQRS (Command Query Responsibility Segregation)?
More Microservices Architecture Questions
View all →- Intermediate What is event-driven architecture and how does it apply to microservices?
- Intermediate What is CQRS (Command Query Responsibility Segregation)?
- Intermediate What is event sourcing in microservices?
- Intermediate What is the Circuit Breaker pattern?
- Intermediate What is the Bulkhead pattern in microservices?