Orchestration and choreography What do they mean ??

Nkugwa Mark William
3 min readOct 24, 2023

--

Orchestration and choreography are two design patterns for coordinating the interactions between different software components or systems. Both patterns can be used in the context of microservices architectures.

  • Orchestration: In orchestration, there is a central controller, called an orchestrator, that is responsible for managing the workflow. The orchestrator decides which components to invoke and when to invoke them. It also handles error handling and recovery.

Analogy: A conductor of an orchestra is an orchestrator. The conductor tells the musicians when to play and what to play. The conductor also listens for mistakes and helps the musicians to recover.

  • Choreography: In choreography, there is no central controller. Instead, the components communicate with each other directly, using a set of well-defined interfaces. Each component is responsible for managing its own part of the workflow.

Analogy: A dance troupe is an example of a choreographed system. The dancers know the steps to the dance and they coordinate with each other to perform it. There is no central choreographer telling the dancers what to do at each moment.

Example:

Let’s say we have a microservices architecture for an e-commerce website. The following steps are involved in processing an order:

  1. The customer places an order.
  2. The order service validates the order and checks inventory.
  3. If the order is valid and there is inventory, the order service creates a payment order.
  4. The payment service processes the payment.
  5. If the payment is successful, the order service creates a shipping order.
  6. The shipping service ships the order to the customer.

We can use orchestration or choreography to coordinate these steps.

Orchestration:

In an orchestrated system, there would be a central orchestrator that would be responsible for managing the workflow. The orchestrator would know the steps involved in processing an order and it would invoke the appropriate services in the correct order.

The orchestrator would also be responsible for handling error handling and recovery. For example, if the payment service fails, the orchestrator would need to roll back the order.

Choreography:

In a choreographed system, there would be no central orchestrator. Instead, the services would communicate with each other directly to process the order.

For example, the order service would send a message to the payment service to request payment. The payment service would then process the payment and send a message back to the order service to indicate whether or not the payment was successful.

If the payment was successful, the order service would then send a message to the shipping service to request shipping. The shipping service would then ship the order and send a message back to the order service to indicate that the order has been shipped.

Which approach should you use?

The best approach to use depends on the specific needs of your system. If you need to handle complex workflows or you need to have tight control over the order of execution, then orchestration is a good choice.

If you need a more flexible and scalable system, then choreography is a good choice. However, it is important to note that choreographed systems can be more difficult to debug and maintain.

In many cases, it is possible to use a combination of orchestration and choreography. For example, you could use orchestration to manage the overall workflow, but use choreography to handle specific interactions between services.

--

--

Nkugwa Mark William

Nkugwa Mark William is a Chemical and Process engineer , entrepreneur, software engineer and a technologists with Apps on google play store and e commerce sites