What is the Saga Pattern?#

Distributed architectures cannot utilize database-level two-phase commit locks without severe performance loss. The Saga pattern breaks complex business operations into sequences of local transactions, executing compensating reverse transactions if any step fails.

Everyday Analogy#

Booking a holiday trip: you book a flight, hotel room, and car rental. If the hotel reservation fails, the platform automatically cancels the rental car and plane ticket to restore your original itinerary.

Architectural Approaches#

  • Orchestration: A central coordinator orchestrates each microservice step
  • Choreography: Autonomous services react to published domain events without a central coordinator