InterviewKata
Software architecture · Level 4: Communication and integration · Module 21 of 46

Orchestration and choreography

A business workflow that spans several services (place an order: reserve stock, take payment, book a courier, confirm) needs coordination. Either one component directs the steps (orchestration), or each service reacts to the others' events and the workflow emerges (choreography). The choice decides who knows the state of an order, who handles failures, and how many places change when the workflow does. This module also covers the gateway and aggregation patterns that sit at the edge of most distributed systems.

1. The idea

An orchestra or a dance floor. An orchestra has a conductor: every musician watches one person, who knows the whole score and can stop and restart a passage. A dance floor at a party has no conductor: each dancer reacts to the music and to the people near them. The party scales to any size and survives anyone leaving; but if you want to know what's happening across the room, you have to ask around.
OrchestrationChoreography
Who knows the workflowThe orchestrator, in one placeNobody; it's spread across the services' event handlers
Workflow stateHeld by the orchestrator: one query answers "where is order 81?"Spread out; ask each service, or keep a separate tracker
Error handlingThe orchestrator decides and compensatesEach service must listen for failure events and undo its own part
CouplingServices know nothing of each other; the orchestrator knows them allServices know the events they react to
Scale and responsivenessThe orchestrator can become a bottleneckNo central component; very scalable
Changing the workflowOne placeSeveral services' handlers

A middle way is the front controller: choreography, but the first service in the flow also tracks the workflow's state by listening to every event, so status questions have one place to go.

At the edge: gateway and aggregation

2. How it works

"Where is my order?" both ways

A gateway aggregating three services

The order page on a phone needs the order, its shipment and the customer's loyalty points. Watch the gateway gather them, including when one is slow.

3. Try it yourself

Design the failure path

An order workflow has four steps, each with a compensating step that undoes it. Choose the coordination style and which step fails, and read every message that follows, in order.

4. Trade-offs

Control vs scale

Orchestration gives one place for workflow logic, state and errors. Choreography removes the central component and its bottleneck, at the cost of workflow logic scattered across services.

Simple flows vs complex ones

Choreography shines for simple fan-out ("something happened, several react"). As steps, branches and compensations multiply, an orchestrator keeps the flow understandable.

Gateway features vs gateway logic

Cross-cutting features (auth, rate limits, routing) belong in a gateway. Business rules don't: a gateway full of logic becomes the ESB of Module 13.

Aggregate vs let clients call

Aggregation saves clients many round trips over slow mobile networks, and adds a component that must handle partial failures and timeouts sensibly.

5. In real projects

Use both. A common shape: an orchestrator for the core, failure-sensitive workflow (checkout, claims, onboarding), publishing events at the end that other services react to by choreography (analytics, loyalty, recommendations).

Workflow engines such as Temporal, Camunda, AWS Step Functions and similar tools provide durable orchestration: the workflow's state survives crashes, timers can wait for days, and each step's history is visible.

Model the workflow before choosing. Draw every step, its compensation and every failure branch. If the drawing is one straight line with no undo, choreography is fine; if it branches and compensates, an orchestrator will save you.

Say it in the interview

Two-sentence answers
  • "Orchestration or choreography?" Orchestration when the workflow has many steps, branches and compensations, or its state must be easy to query. Choreography for simple reactions where scale and decoupling matter more.
  • "Who handles a failure in choreography?" Each service listens for failure events and undoes its own work. It works, but the overall error path is spread across services, so it needs careful design and tracing.
  • "Why an API gateway?" One entry point for authentication, rate limiting and routing, and often aggregation so clients make one call. Business logic stays in services.
Red flags interviewers notice
  • Choreography for a long, compensating workflow, with no way to see an order's state.
  • An orchestrator that also holds the business data of every service.
  • A gateway aggregation that fails the whole page when one service is slow.

6. Remember it

Memory hook: "Conductor or dance floor"A conductor knows the score and stops the music on a mistake; a dance floor scales but nobody sees the whole room.
How this hook works: what "conductor or dance floor" means

What the slogan means, phrase by phrase

"Conductor"
Orchestration: one component directs every step and knows where things stand.
"dance floor"
Choreography: everyone reacts to events; no one holds the whole picture.

Why this picture fits: it captures the trade-off in one image: control and visibility versus scale and independence.

The story → the concept

MusicWorkflow
The scoreThe workflow definition
Conductor stops and restarts a passageOrchestrator compensates after a failure
Dancers reacting to each otherServices reacting to events
The doorman at the venueThe API gateway

The trap it saves you from

Choosing choreography because it sounds more decoupled, then discovering nobody can tell where an order is.

7. Common mistakes

No failure designEither style works for the happy path. The difference is all in failures: draw every compensation before choosing.
The god orchestratorAn orchestrator that makes business decisions every service should own. It should coordinate, not decide.
Hidden choreographyA workflow nobody can draw, because it lives in six services' event handlers. Document it, and trace it.
All-or-nothing aggregationOne slow service failing the whole response. Use timeouts and return partial results where the screen can cope.

8. Design exercise (30 minutes)

  1. Model a workflow (10 min). Pick a multi-service workflow you know. List its steps and the compensation for each.
  2. Count the branches (10 min). How many ways can it fail? Who handles each today?
  3. Choose (10 min). Orchestration, choreography or a front controller? Write the decision with its trade-off in three sentences.

9. Self-check quiz

In orchestration, where is the workflow's state?

One place knows every workflow's progress and can answer status questions.

In choreography, how does a failure get compensated?

The error path is distributed like the happy path.

What is a front controller?

It keeps choreography's decoupling but gives status queries one home.

An aggregating gateway's loyalty-points call times out. What should it usually do?

Partial responses keep the page useful; the screen shows the missing piece as unavailable.

Which belongs in an API gateway?

Cross-cutting edge concerns, not business logic.

10. Go deeper

ResourceTimeWhy
Saga pattern (Chris Richardson)15 minOrchestrated and choreographed sagas compared.
API gateway and backends for frontends10 minThe edge patterns, with their variations.
Temporal workflows20 minHow a durable workflow engine runs orchestration that survives crashes.