Retrieve Data From Multiple Microservices

Retrieve Data From Multiple Microservices

In microservice pattern, microservices are suppose to own their own database to achieve best independent scalability. However, highly distributed data brings challenges to client app that needs data from multiple microservices which is a common requirement. For example a Order screen may need data from User, Product and Shipping microservices. Calling multiple APIs and aggregate information on the client side is not a efficient and clean solution. The following two solutions are common patterns to use.

API gateway

Create a aggregation microservice, as an API Gateway, to provide data to the client side. Sometimes the API gateway is also called the backend for frontend (BFF) layer. API gateway sit between client app and backend microservices.

Having a single API Gateway aggregating many internal microservices can be a risk as it acts as a monolithic aggregator/orchestrator thus making backend microservices not loosely coupled anymore. Therefore, the API Gateways should be segregated based on business boundaries and client apps. Using multiple API gateway is usually better and we should build each client app its own customized API gateway (or BFF) to achieve best efficiency.

Besides the risk of introducing service coupling, API gateway can also add service response time and also requires additional development cost.

View tables

Create read only tables with format customized for client apps. Data are populated in advance from multiple microservices. This table can also serving the reporting purpose. The view tables can improve the call efficiency significantly since no real-time data aggregation is required.

One of the downsides of this solution is that the data in the view table may have some time delays thus we need to embrace eventual consistency of data.




To view or add a comment, sign in

More articles by Lixin C.

  • Solution Architect - part 1

    Solution Architects (SA) are responsible for providing solutions to fulfill business requirements by working with…

  • Chaining HTTP Calls Using Observables With RxJS

    Sometimes we need to make multiple HTTP calls in a specific order to get data. The data from previous call are either…

  • RxJS Concise Demo - Creation Operators

    RxJS operators are functions that can create or process Observables. Creation operators are used to create new…

  • Async Controller Methods For Scalability

    In API action methods, it is very common to call a database or another web resource to get requested data. Getting data…

  • Angular Component Lifecycle Hooks

    Angular lifecycle hooks allows you to implement critical logic at the right time of a component's lifecycle. During the…

  • HTTP Status Code Short listed

    Commonly Used HTTP Status Codes for Web Services. 200 => OK, general indication of request success.

  • Network Layers for Software Engineers

    Sending messages to another person using web browser or mobile app is not surprisingly easy nowadays and most people…

  • Implementing a Fixed-Window Median Data Stream With Heaps

    A data stream is like a pipe with moving data inside. Here I only consider integer numbers as data and try to find the…

  • Test Your Testing Strategy with A Dice Game

    1. Project background Sometime in last year I got interested in how does the 3D web rendering engines work.

Explore content categories