Most of you have probably heard of the Saga pattern in microservice architectures. It helps coordinate a business process that spans multiple services and cannot be handled by a single transaction.
Each participant in a Saga commits a local change. If a later step fails, the system runs compensating actions to bring the process back to an acceptable state. But who should manage the sequence of steps: the services themselves, or a dedicated coordinator?
Orchestration or choreography?
With choreography, services react to one another’s events, and there is no central coordinator. With orchestration, a dedicated coordinator defines the order of actions, tracks the process state, and decides what to do when something fails.
The choice depends on the complexity of the business process and the level of control it requires. Let’s compare both approaches using the same example.
Example: placing an order
Choreography: services react to events
Consider an order workflow. The Order service publishes an OrderPlaced event. The Inventory service checks availability and attempts to reserve the items. It then publishes either StockReserved or StockUnavailable.
After receiving StockReserved, the Payment service processes the payment and publishes either PaymentCompleted or PaymentFailed. Once payment succeeds, the Shipping service creates a shipment.
No single service owns the entire workflow: each participant reacts to the events it needs. The services remain independent, but the order’s state is spread across their handlers. When something goes wrong, understanding what happened may require tracing a chain of events across several services.
For example, if payment fails, the Inventory service needs to receive a failure event and release the reservation. If a shipment cannot be created after payment succeeds, the system needs a recovery step: retry, cancel the payment, or route the order for manual handling.
Choreography is easy to follow while the process is short and reactions are simple. As branches and recovery paths accumulate, it becomes harder to understand.
Orchestration: one component coordinates the steps
An Order Saga can manage the workflow instead:
- Ask the Inventory service to reserve the items.
- Start payment after the reservation is confirmed.
- Request shipment creation after payment succeeds.
- If payment fails, ask Inventory to release the reservation.
- If shipment creation fails, retry or run the agreed recovery flow.
The orchestrator tracks the order’s state and decides what to do when a step fails or times out. The process is easier to observe, but the coordinator itself must be operated and maintained. Its role is to manage the sequence of steps, not to take business logic or data ownership away from the services.
How to choose
| Choreography | Orchestration | |
|---|---|---|
| Process | Short and mostly linear | Long-running or branching |
| Process state | Reconstructed from events | Tracked by the coordinator |
| Failure handling | Distributed across participants | Defined in the workflow logic |
| Main cost | Harder to trace as the process grows | An additional component to operate |
If the steps are simple and services can react to events independently, choreography may be enough. If the team needs to track the state of each order, handle timeouts, and manage several failure paths, orchestration gives the process an explicit owner.
One thing remains true in either approach: compensation is not a transaction rollback. Releasing reserved stock or cancelling a payment is a new action, and that action can fail too. Handlers need to be idempotent; retries, timeouts, stuck orders, and manual recovery should be planned for in advance.
Top comments (0)