Saga vs. Workflow
Both sagas and workflows are sequential multi-step processes, but they serve different purposes.
Key Differences
| Feature | Saga | Workflow |
|---|---|---|
| Purpose | Transactions with rollback | Data pipelines |
| Compensation | ✓ Every step has an undo | ✗ No rollback |
| Data passing | Limited | ✓ Output → Input |
| On failure | Rollback all steps | Stop or skip |
| Use case | Orders, payments, bookings | ETL, analysis, reports |
When to Use Sagas
Use sagas when:
- Steps have side effects that need to be undone
- Consistency is critical
- You need all-or-nothing semantics
Examples: Order processing, payment flows, booking systems
When to Use Workflows
Use workflows when:
- Steps transform data sequentially
- No rollback is needed
- Each step's output feeds the next step's input
Examples: Data pipelines, report generation, content processing
Decision Tree
Does the process need rollback?
├── Yes → Use a Saga
└── No
└── Does each step's output feed the next?
├── Yes → Use a Workflow
└── No
└── Are steps independent?
├── Yes → Use a Pool
└── No → Use a Supervisor