Service Aggregator Pattern
In this tutorial, we are going to discuss Design Patterns of Microservices architecture which is the Service Aggregator Pattern. We will use this pattern and practice when designing microservice architecture.
In order to minimize service-to-service communications, we can apply Service Aggregator Pattern.
In Microservices Architecture, we split a large, complex application into small, autonomous, independently deployable services. Therefore, it’s necessary to think about how to collaborate the data returned by each service. In the IT industry, an aggregator refers to a website or program that collects related items of data and displays them.
So, in microservices the Aggregator Design Pattern is a service that receives a request, then makes requests of multiple services, combines the results, and responds to the initiating request.
Basically, The Service aggregator design pattern receives a request from the client or API Gateways, then dispatches requests of multiple internal backend microservices, and then combines the results and responds back to the initiating request in 1 response structure.
By Service Aggregator Pattern implementation, we can reduce chattiness and communication overhead between the client and microservices.
Let’s see the image, You can find here is AddItem Aggregator Microservice which basically orchestrates the AddItem into Shopping Cart operation. And it aggregates requests to several back-end microservices which’s are Product, Shopping Cart, and Pricing.
So we can say that this pattern isolates the underlying AddItem operation that makes calls to multiple back-end microservices, centralizing its logic into an AddItem Aggregator Microservice.
Also, we can apply this pattern to our e-commerce application architecture when querying data from backend systems.