No Shared Transaction
A single database transaction cannot span several microservices, yet a business action like placing an order touches payment, inventory, and shipping. A saga breaks that action into a sequence of local transactions, each in one service, with a compensating action to undo it if a later step fails.
Two Coordination Styles
- Choreography has each service react to events from the previous step, with no central brain.
- Orchestration has a coordinator that tells each service what to do next and triggers compensations on failure.
Compensation
There is no global rollback. If shipping fails after payment succeeded, the saga runs a compensating step such as refunding the payment. Compensations must be idempotent because they may be retried.
Consistency Reality
A saga gives eventual consistency, not isolation. Other readers can see intermediate states, so design steps to tolerate that and to be safely retried.
Key idea
A saga sequences local transactions across services with idempotent compensating actions to undo earlier steps, trading isolation for eventual consistency without a global transaction.