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
- Email Notification to Manager
- Notify HR to schedule 1:1 interview
- Temporary block critical access till decision is finalised.
How do we model and implement this flow
So we will be involving 3 services
- Notification
- HR
- Access
Now the Real Game is we can implement this model in two ways.
- Orchestration
- 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.
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…
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.
- Most modern system are inclined towards- Choreography
- Loosely Coupling- The core of microservice
- Extensible- Adding new type of service should be simple
- Hexible- Services should be independent to drive their own changes
- 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. 💡