Skip to main content
InterviewHubPRO
Section Overview
Q22

Question 22 of 50

Part 2: Behavioral Patterns & Communication (11 - 24)

44%
Design Patterns (GoF) (50 Qs)•Part 2: Behavioral Patterns & Communication (11 - 24)

What is the SAGA Pattern for Distributed Transactions?

senior LevelState ManagementSystem DesignDatabases & SQL

In Simple Words: Replaces slow 2-Phase Commit (2PC) across microservices with a sequence of local transactions:

  • Each service executes a local transaction and publishes an event that triggers the next service's transaction.
  • Compensating Transactions: If Service 3 fails (e.g. payment rejected), the saga executes a series of compensating transactions in reverse order to roll back earlier changes (e.g. release reserved inventory).
  • Implemented via Choreography (services react to events) or Orchestration (central saga orchestrator directs steps).