In a microservices architecture, a single business process (e.g., "Order Fulfillment") often spans multiple services, each with its own database. Traditional Two-Phase Commit (2PC) is often avoided in 2026 due to its blocking nature and poor scalability. The Saga Pattern provides an alternative by treating a distributed transaction as a sequence of local transactions.
A Saga is a sequence of local transactions T_1, T_2, ..., T_n. Each local transaction updates the database and publishes an event or message to trigger the next step.
There is no central coordinator. Each service produces and listens to events from other services.
A central Orchestrator (State Machine) manages the Saga logic. It sends commands to services and handles their responses.
To simplify recovery, modern Sagas categorize steps into three types:
| Type | Description |
|---|---|
| Compensatable | Steps that can be undone (e.g., "Reserve Item"). Requires a matching C_i. |
| Pivot | The "Point of No Return." If this succeeds, the Saga must complete. |
| Retriable | Steps after the pivot (e.g., "Send Receipt"). Designed to eventually succeed via retries. |
Sagas are fragile without two supporting patterns: