Orchestration-Based Sagas
What You'll Learn
You'll learn how a central coordinator can manage saga transactions by explicitly controlling each step and its compensations, offering greater visibility and control than choreography-based approaches.
The Core Idea
In an orchestration-based saga, a single orchestrator service acts as the conductor of your distributed transaction. Unlike choreography (where services react to events independently), the orchestrator explicitly tells each service what to do next, tracks the overall progress, and decides when to trigger compensations if something fails.
Think of it like a wedding planner versus guests coordinating themselves. The choreography approach has guests watching each other and reacting ("Oh, the ceremony ended, time for dinner"). The orchestration approach has a wedding planner directing everyone: "Now the ceremony. Good. Now move to dinner. Okay, time for speeches."
How It Works
The orchestrator maintains a state machine representing your saga workflow:
- Orchestrator initiates the first local transaction
- Waits for confirmation from that service
- Decides the next step based on the result
- Continues sequentially through remaining transactions
- Triggers compensations in reverse order if any step fails
The orchestrator knows the entire saga definition: which services to call, in what order, and which compensation to trigger for each completed step.
Benefits Over Choreography
- Centralized logic: The workflow is explicit and visible in one place
- Easier debugging: You can see exactly where a saga failed
- Better monitoring: Track saga progress through orchestrator state
- Simpler services: Participants don't need to know about the overall flow
Trade-offs
The orchestrator becomes a critical component that must be highly available. It's also a single point coupling—changing the saga flow requires updating the orchestrator.
Key Takeaway: Orchestration-based sagas use a central coordinator to explicitly direct transaction sequences, trading coupling for visibility and control over your distributed transaction flows.