Backend, Data & Security More detail C · Industry convention Platform: Web

Saga Pattern

A saga links several saved steps into one business job. If a later step fails, it retries or adds another step to fix what happened earlier.

See how it works
You might call it distributed sagasaga workflowsaga transaction

See how it works

Original worked exampleSaga Pattern
State & recoverySaga Patternsaga ID + local transaction -> next step; failure -> retry | compensation -> terminal state
TRIP BOOKINGhotel failed
  1. ✓Flight heldflight_tx_7
  2. ✓Card chargedpay_tx_8
  3. !Hotel unavailablehotel_tx_9
↶ Compensation completedsaga: cancelled
KEEP SAFEEach service commits a local step and records what happened.RECOVERRetry forward work or run explicit compensating actions.
saga ID + local transaction -> next step; failure -> retry | compensation -> terminal stateJOB
Saga PatternBackend reliability

Another example

Order `984` reserves stock, authorizes NT$248, and then asks for shipping. Shipping rejects the address. The saga voids the authorization and releases the stock with the same saga ID. It then records the order as compensated.

Main parts

  1. 01Saga ID and state
  2. 02Participating services
  3. 03Local transactions
  4. 04Outcome messages
  5. 05Retry or compensation
  6. 06Audit and manual recovery

Use it when

Use a saga when one business job spans services or data stores. Use it only when one all-or-nothing database step cannot cover the whole job. Define each saved step, next action, retry, fix-up action, and final state.

Do not use it when

Do not add a saga when one database save can finish the whole job. A fix-up action is new work. It can fail or leave a different result. Ask a person when an action is unsafe to undo.

Name used in code

saga ID + local transaction -> next step; failure -> retry | compensation -> terminal state

Before you ship

Check contracts and invariants, authorization, and input limits. Test retries, one-time effects, timeouts, and partial failures. Verify data integrity, compatibility, monitoring, recovery, and rollback.

Request you can copy

Outcome: Design or review Saga Pattern for this system while keeping data correct, secure, and easy to operate. User context: Order `984` reserves stock, authorizes NT$248, and then asks for shipping. Shipping rejects the address. The saga voids the authorization and releases the stock with the same saga ID. It then records the order as compensated. Technical concept or control: Saga Pattern. Why it fits: Use a saga when one business job spans services or data stores. Use it only when one all-or-nothing database step cannot cover the whole job. Define each saved step, next action, retry, fix-up action, and final state. Do not use it when: Do not add a saga when one database save can finish the whole job. A fix-up action is new work. It can fail or leave a different result. Ask a person when an action is unsafe to undo. Engineering requirements: Define inputs, outputs, contracts, and rules that must always hold. Set authorization and input checks. Define failures, timeouts, retries, one-time effects, data moves, and compatibility limits. Operations: Add useful signals and logs that hide sensitive data. Set capacity limits and write an operator guide. Test recovery and rollback. Acceptance criteria: Contract and failure-path tests pass. Data and authorization rules still hold during retries and partial failures. Check performance limits, monitoring, recovery, and rollback. Evidence and limits (evidence boundary): No single official standard controls the whole term. Its meaning may change across teams, platforms, or frameworks. Unknowns to confirm: Where the code runs, data stores, traffic shape, consistency needs, and the security boundary. Also confirm the compatibility period, service goals, and rollback limits.

Check this request

Review the current use of Saga Pattern. Definition: A saga links several saved steps into one business job. If a later step fails, it retries or adds another step to fix what happened earlier. Release checks: Check contracts and invariants, authorization, and input limits. Test retries, one-time effects, timeouts, and partial failures. Verify data integrity, compatibility, monitoring, recovery, and rollback. Before changing code, report the evidence you found, gaps, severity, and the smallest safe fix.

C
How official is this term?

Industry convention

People often use this term at work. The listed sources may support practice or limitations. They do not define every part of the term.

No single official standard controls the whole term. Its meaning may change across teams, platforms, or frameworks.

Scope
Cross-platform saga engineering convention; AWS only supports the cited Prescriptive Guidance patterns
Document status
stable
Checked on
2026-07-30

Evidence sources & scope

Authority source + Term reference · Amazon Web Services · stable Saga patterns Scope: AWS Prescriptive Guidance for saga choreography and orchestration used only as context for a cross-platform engineering convention; not a formal transaction standard Role here: Direct term reference Source covers: canonical name, definition, implementation, usage guidance, avoidance guidance Background source Azure Architecture Center — Compensating Transaction pattern Role here: Helpful background, not a definition

Copy it yourself

The browser could not copy this. Select the request below and copy it yourself.