← All patterns
Data consistency · Architecture pattern

Saga

Coordinate local transactions and compensate completed business steps after failure.

The problem

Checkout spans inventory, payment and shipping, each with its own data. A later failure leaves earlier steps committed.

When it fits

A business operation spans independently committed services and can define compensations or a recovery process.

The whole architecture

Architecture diagram

A durable coordinator runs local service transactions and records business compensation when a later step fails.

Blue arrows are service/data calls. Compensation names describe new business actions, not a global rollback.

100%

Scroll to pan. Select a component for its role.

saga architectureA durable coordinator runs local service transactions and records business compensation when a later step fails. Blue arrows are service/data calls. Compensation names describe new business actions, not a global rollback.Workflow coordinationIndependent service transactionsclient → coordinator: startcoordinator → workflow: checkpointcoordinator → inventory: reserve / releasecoordinator → payment: authorize / reversecoordinator → shipping: shipinventory → stock-data: local commitpayment → payment-data: local commitshipping → shipping-data: local commitstartcheckpointreserve / releaseauthorize / reverseshiplocal commitlocal commitlocal commitThe product needs a way to report pending and recovered outcomes.Checkout clientBegin a workflowAn orchestrator is one saga coordination approach; choreography is another.Saga coordinatorDurable workflow stateRetain enough progress to retry or reconcile after a coordinator crash.Workflow storeCompleted / pendingstepsRelease is a compensating business operation.Inventory serviceReserve / release stockPayment reversal can fail and may require reconciliation.Payment serviceAuthorize / reverseIrreversible steps need an explicit point-of-no-return policy.Shipping serviceArrange shipmentThis service owns its own transaction domain.Inventory dataLocal transactionThis is separate from inventory and shipping commits.Payment dataLocal transactionA later failure does not erase earlier committed business history.Shipping dataLocal transaction

Select a component, or focus it and press Enter, to read its role.

Walk through the design

Follow one operation

Select a step to highlight its participants. This conceptual walkthrough is separate from challenge scoring.

Arrows show the conceptual relationships used by this walkthrough.

CoordinatorActive in this stepInventoryActive in this stepPaymentWaitingShippingWaiting
Step 1 of 3

Reserve inventory

The coordinator requests a local inventory reservation transaction.

Trade-offs to make explicit

  • Compensation is a new business action; it does not erase history or provide database rollback.
  • Concurrent operations can observe intermediate states. Define reservations, isolation strategies and points of no return.

Failure modes to plan for

  • A compensation can fail and require retries or manual reconciliation.
  • Repeated commands need idempotent handling, and irreversible steps need an explicit recovery policy.
Before you build

Explain your decision

If a refund fails after inventory is released, what durable state tells an operator which action still needs recovery?

Use Plan & estimate inside practice to record your assumptions and trade-offs.

Connect concept to practice

Related challenges

Browse challenges →

These links open the original challenges. Existing round unlocks, completions and points apply.

One transfer, two attempts

Related prerequisite in idempotent local effects. This challenge uses one SQL transaction domain and does not score cross-service sagas.

Open challenge →

Further reading

Microsoft · Saga ↗

Original PractiseGrid explanations and conceptual diagrams, with primary references for further study. Dedicated scored exercises can be added as coverage grows.