Back

Orchestration or Choreography- A Microservice Game Play

Feb 07 2023
10min
🕐 Current time : 29 Mar 2025, 05:04 AM
The full Astro logo.

Let’s Design a system to understand this game play.

Technical Requirements

We need to build an Exit Management System, whenever an employee hashtag#Resign we have to send

  1. Email Notification to Manager
  2. Notify HR to schedule 1:1 interview
  3. Temporary block critical access till decision is finalised.

How do we model and implement this flow

image

So we will be involving 3 services

  1. Notification
  2. HR
  3. Access

Now the Real Game is we can implement this model in two ways.

  1. Orchestration
  2. Choreography

Let’s implement via Orchestration

Orchestration :- The brain, or logic component, of microservices orchestration is the orchestrator, which allocates tasks to the microservices. The orchestrator selects the workflow and assigns tasks to the microservices upon receiving a transaction request or a query. Each microservice is just concerned with the task that is allocated to it, not the workflow as a whole.

It’s enough of texts now go for actual design.

image

As soon as an employee resign, the EMS service invokes API of other services like - what needs to be done.

All the Three services need not to be invoked one after other.

The main Agenda is in this situation Services are dumb, Only EMS service knows what needs to be done on each involved service, and it thus ORCHESTRATES the required action.

In some situations, the orchestrator needs to handle, manage and track a much complex workflows.

Now can we convert above model into Choreography please… With choreography, decision-making power is dispersed among the microservices in a more bottom-up manner. It is a decentralised system as a result. The microservices are a component of the logic and decision-making process, and each one knows when and how to interact with other services, carry out tasks, and other things. Not last but lease Choreography leads the foundation of EVENT DRIVEN ARCHITECTURE

Move to design now…

image

The EMS service, to which HR and Access have subscribed, sends out an event notification when an employee resigns. The four services involved are decoupled after they receive the event and act accordingly. If we want to expand our system to accomplish more, a new service can simply subscribe to relevant events and handle them. So, which one We should USE.

before jumping on conclusion, i just want to make few points.

  1. Most modern system are inclined towards- Choreography
  2. Loosely Coupling- The core of microservice
  3. Extensible- Adding new type of service should be simple
  4. Hexible- Services should be independent to drive their own changes
  5. Robust- Working not affected no matter the number of subscriber.

But with Choreography approach we need to Implement complex observability and track what’s happening Although a lot of people adopt & prefer Choreography, NOT making Orchestration BAD.

At the end Like Life Tech decisions are not BINARY too my friend, there gonna be always an use/business case. 💡

Read more in this Series:

Find me on

GitHub LinkedIn LinkedIn X Twitter
© 2022 to 2025 : Amit Prakash