With the increasingly collaborative scenarios in which APIs are used, as well as the growing maturity and scale of microservice architectures, the idea of API coordination has become a hot topic.
Sam Newman and Phil Calçado have popularized the “Backend for Frontend (BFF)” deployment pattern, which describes a topological approach to coordinating service API calls. However, coordinating API calls in a distributed software system is not a new problem. It has been a concern even from the early days of SOA. In my experience, software architects can often conflate the different types of coordination when trying to determine function placement in their application integration efforts. To help address this pitfall, here is a classification system I use:
API aggregation
Aggregation is the stateless assembly of multiple responses in a fan-out/fan-in request/reply scenario. This is common when you have a remote network client who wants to reduce chattiness to the back end, such as in the BFF pattern. This pattern can be handled by an infrastructure intermediary like an API gateway.
API orchestration
Orchestration is the stateful coordination of backend requests and responses, where the sequence and content of interactions depend on prior responses. Historically, this has been implemented in stateful middleware (e.g. workflow engines), but may be better implemented in composite services owned by business-aligned teams.
API choreography
Choreography is the reactive coordination of component actions based on events in a distributed system. This is a higher level pattern that is best implemented by taking an event-driven approach to engineering a system of multiple components, not implemented strictly through middleware. Within the API choreography pattern, there is an implicit need for “event broadcasting” – the asynchronous distribution of events from one component to many subscribers – and this event distribution function is a good candidate for middleware implementation.
I have found that delineating API coordination in this way is helpful when determining the appropriate approach to implementation. Check out this article for more resources on application integration in general.