Spring Boot & Microservices (50 Qs)•Part 3: Microservices, Distributed Systems & Observability (25 - 35)
What is the Saga Pattern in Microservices (Choreography vs Orchestration)?
senior LevelSystem DesignMicroservicesData Structures
In Simple Words: Manages distributed transactions across microservices without two-phase commit (2PC):
- Choreography: Each service publishes an event (e.g.,
OrderCreated -> PaymentProcessed -> InventoryReserved), and services react. Simple, but hard to track. - Orchestration: A central Saga Orchestrator coordinates each step and triggers Compensating Transactions (e.g., refund payment, release stock) if any intermediate step fails.