Video in progress
How do the choreography and orchestration variants of a saga differ?
In choreography there's no center: each service listens to an event, does its step and emits a new event. In orchestration a single orchestrator service commands the steps in order and manages compensation if something fails.
📖 Answer
Example: order → stock reservation in the warehouse → payment → delivery.
Choreography: order-service emits OrderCreated, inventory-service hears it, reserves stock and emits StockReserved, payment-service hears that and takes the payment, and so on. If the payment fails, PaymentFailed is emitted and inventory-service releases the reservation.
Orchestration: the OrderSaga orchestrator sends inventory the command "reserve stock", waits for the reply, then tells payment "take the payment". If something fails, it sends the compensation commands itself. The saga state is stored in the orchestrator's database.
| Choreography | Orchestration | |
|---|---|---|
| Getting started | easy, no extra service | you have to write an orchestrator |
| Understanding the flow | you have to trace through events | visible in one place |
| Coupling | services know each other's events | services know only the orchestrator |
| With many steps | gets tangled | manageable |
In practice, choreography is enough for simple flows with 2-3 steps. When the steps go beyond five, or when I need a quick answer to "which order got stuck at which stage?", I move to an orchestrator. Workflow engines like Camunda or Temporal are used for the same purpose.
Sign up to mark studied questions and save your progress.