Skip to content

01. Context

João Neves edited this page Sep 11, 2019 · 1 revision

One of the main principles of the microservices architecture is Decentralized Data Management as written by Martin Fowler and James Lewis in 2014 which explicitly recognize that:

"consistency may only be eventual consistency and problems are dealt with by compensating operations."

It is interesting that this has similarities to the saga concept proposed quite before, in 1987, by Hector Garcia-Molina and Kenneth Salem:

A LLT [Long Lived Transaction] is a saga if it can be written as a sequence of transactions that can be interleaved with other transactions. (...) either all the transactions in a saga are successfully completed or compensating transactions are run to amend a partial execution.

In the microservices context, business processes usually stretch across the boundary of individual services, and therefore this means that transactions will be executed by a service which communicates with other services.

This communication can be mediated using Choreography or Orchestration. Sam Newman clarifies the two in his book Building Microservices:

With orchestration, we rely on a central brain to guide and drive the process, much like the conductor in an orchestra. With choreography, we inform each part of the system of its job, and let it work out the details, like dancers all finding their way and reacting to others around them in a ballet.

The differences between the two are all about central control and governance vs flexibility and serendipity. As an example, one of the risks of orchestration is migrating business logic out of services and into a single big ball... orchestrator, while choreography runs the risk of chaos as the control is not centralized in a single unit. You can find here a great presentation approaching the topic.

There is no silver bullet. Choosing between the two should be well balanced, and a system can live with both simultaneously in different execution contexts.

However, while I found a lot of orchestration/workflow libraries and servers, there are not I was not able to find much software helping developers to use Choreography, except for observability or tracing tools. This was the beginning of Sapher.

Clone this wiki locally