As per Dzone, a survey done with 345 enterprises, 63% of companies say they used Microservices architecture with improved employee efficiency and customer experience. In the same survey enterprises also agreed that they saw higher benefits in using an orchestration engine in their Microservices architecture. On the other hand StackOverflow data says companies usually take Choreography approach for their Microservices without really knowing it.
In last year’s Accion Global Innovation Summit, Hemesh Thakkar our design and architecture lead presented a session on “Orchestration vs Choreography”.
Hemesh discussed the differences between implementing Choreography of Microservices and Orchestrating them. He also stated various challenges with Choreography and Orchestration approaches and how Accion Labs’ Breeze blueprint uses platforms like Camunda and Zeebe to overcome these challenges.
Listen to Podcast: Orchestration vs Choreography of Microservices
To illustrate the challenges that need to be addressed in a microservices architecture, let us consider a hypothetical application. We have several capabilities in the application that need to work with each other in order to perform certain business goals. For example, if we are building an e-commerce application, this could consist of several microservices such as:
All these microservices would work independently, and can be customized, scaled and deployed independently. However, a customer’s purchase journey encounters all these independent microservices. Hence the overall business transaction that spans the scope of multiple microservices needs to be controlled. The transaction needs to be seamless, and should not be broken. All the microservices need to work together to be able to fulfill an order and that will be the real value for the business.
The pattern of requirements where business transactions require cross boundary coordination between multiple microservices is called a saga or workflow pattern. There are several models for implementing such workflows or sagas in a microservices environment. These models differ in the level of independence provided to each microservice and the method of control for them to work with each other seamlessly.
The three models that distinctly differ in the two aspects of independence and control are:
To understand how these models work, consider an example of a group of dancers dancing on a stage. The dance looks appealing when all the dancers coordinate with each other well. Each dancer could be doing their own moves, but they coordinate with each other to make the overall dance look appealing.There are several ways in which these dancers could coordinate.
One way for the dancers to coordinate with each other is for all the moves of each dancer being rehearsed and predetermined. Each dancer closely watches other dancers and knows each move made by them. If one dancer makes a wrong move, all dancers will get affected and the entire performance may suffer. This is an example of Tight Coupling.
Another model is to allow each dancer to move independently, but have a predefined set of cues for the dancers to coordinate with each other. These cues are like signals that the dancers watch for, and coordinate their moves based on the cues.The cues are defined and agreed upon before the actual performance. Each dancer is free to perform their own moves during the actual performance and only provides cues to other dancers. This allows the dancers to be independent but still makes the entire performance properly coordinated. Even if one dancer makes a move that other dancers do not know, the overall dance still works well as long as the cues are provided properly. This is an example of Choreography. This model works well when the predetermined set of cues can be well defined.
The third option is to appoint one dancer as a conductor or orchestrator. The conductor or orchestrator communicates to all other dancers to coordinate the dance. All other dancers depend upon the conductor for their performance. This is an example of Orchestration. This model provides the maximum level of control to the conductor, but also makes the conductor a single point of failure.
Finding the Right Balance: In the Orchestration model, the conductor can provide different levels of independence to each individual performer. Sometimes, all moves can be controlled in tightly controlled sequences, while there could be sequences where individual dancers are provided more freedom to improvise. It is this factor that can be leveraged to provide a meaningful balance between Choreography and Orchestration. Thus, Orchestration provides flexibility to an architect that can determine the levels of control and independence based on business use cases.
Similar to the dancers coordinating on stage, multiple microservices can also be coordinated using tight coupling, choreography or orchestration.
One important factor that differentiates the above options is the nature of control between individual microservices. The first option does not provide any such control. The second option is referred to as Orchestration, while the third is Choreography. The following section describes these patterns in further detail.
When we implement Choreography under Microservices architecture, we will have one service calling another and another service would call the third one, so on and so forth.
But there are several disadvantages in performing this:
Now we talk about implementing Orchestration under Microservices architecture. In that scenario you have an event stream where the upstream microservices will publish events and then downstream microservices will listen to them. But this particular implementation is on the grey side and certain solution architects consider it as more of choreography vs orchestration. Since there is a central authority involved which is the event queue, we can consider it as orchestration.
Another approach is where you develop a composite microservice, which coordinates all the service calls by itself so the frontend will call the composite service and it would take care of all the other services.
But again with the Orchestration approach you may encounter certain advantages and disadvantages:
Hence you implement orchestration or choreography in your microservice architecture, you will solve a problem but create two new.
New architecture that involves microservices has its own challenges. Camunda, the company behind the orchestration framework, did a survey with their customers and asked them the pain points in implementing microservices architecture especially related to workflows.
The two biggest problems that emerged were:
Whether you choose Orchestration or Choreography these challenges will remain prevalent while implementing Microservices. Few comments on the StackOverflow discussion page say that companies need to focus on the business logic. Where a single point of logic does the job, you perform Orchestration. Where a problem cannot be covered by a centralized logic, you perform Choreography.
Talk to our expert today to know more about Microservices Orchestration and Choreography and how you can implement Microservices architecture with Orchestration or Choreography for your business.