Software Architecture Foundations · Domain Boundaries and Consistency

Sagas, Outbox, and Consistency

Coordinate distributed workflows without pretending one global transaction exists.

Sagas, Outbox, and Consistency

Distributed systems rarely get one safe transaction across services. Sagas coordinate multi-step business workflows with local transactions and compensating actions. The transactional outbox pattern stores state changes and outgoing events in the same local database transaction.

When To Use

Use sagas when a business process spans services, such as order creation, payment capture, inventory reservation, and shipment. Use outbox when a service must reliably publish events that correspond to committed database changes.

Key Design Points

  • Make each step idempotent.
  • Define compensation for steps that can be undone.
  • Use correlation IDs for tracing a saga.
  • Monitor stuck, retried, and dead-lettered workflow steps.

Comparison

Pattern Best Use Tradeoff
Local transaction Single-service invariant Cannot span service boundaries
Saga Multi-service workflow Compensation and partial failure complexity
Outbox Reliable event publication Requires polling/relay and cleanup

Practice questions

How would you explain sagas and the transactional outbox in a production design review?

Answer

Summary

I would explain sagas and the transactional outbox as a design choice driven by requirements, constraints, and failure modes.

Longer Answer

I would explain sagas and the transactional outbox as a design choice driven by requirements, constraints, and failure modes. The main decision is how to keep state changes and integration events reliable without distributed transactions.

Key Points

  • I would explain sagas and the transactional outbox as a design choice driven by requirements, constraints, and failure modes
  • The main decision is how to keep state changes and integration events reliable without distributed transactions
  • Good architecture answers connect sagas and the transactional outbox to scalability, reliability, security, cost, and team operations
  • Use the answer to connect the concept back to a realistic production or interview scenario for 'How would you explain sagas and the transactional outbox in a production design review?'

Comparison / Tradeoffs

Aspect Notes
Core idea I would explain sagas and the transactional outbox as a design choice driven by requirements, constraints, and failure modes.
Practical tradeoff Good architecture answers connect sagas and the transactional outbox to scalability, reliability, security, cost, and team operations.

Why

Summary

Good architecture answers connect sagas and the transactional outbox to scalability, reliability, security, cost, and team operations.

Longer Answer

Good architecture answers connect sagas and the transactional outbox to scalability, reliability, security, cost, and team operations. In practice, explain where this shows up in production code, what tradeoffs matter, and how you would justify the choice in an interview.

Key Points

  • Good architecture answers connect sagas and the transactional outbox to scalability, reliability, security, cost, and team operations
  • In practice, explain where this shows up in production code, what tradeoffs matter, and how you would justify the choice in an interview
  • In an interview, relate 'How would you explain sagas and the transactional outbox in a production design review?' to implementation decisions, tradeoffs, and operational impact
  • Use the answer to connect the concept back to a realistic production or interview scenario for 'How would you explain sagas and the transactional outbox in a production design review?'

Comparison / Tradeoffs

Aspect Notes
Core idea Good architecture answers connect sagas and the transactional outbox to scalability, reliability, security, cost, and team operations.
Practical tradeoff In an interview, relate 'How would you explain sagas and the transactional outbox in a production design review?' to implementation decisions, tradeoffs, and operational impact.

Open in the app to mark lessons complete, take notes and track your progress.