Since your application use microservice architecture and the data is spread accross multiple service. Let’s say you open the home page and search for bug spray. The UI of your application need list of product data, customer review data, inventory data, and maybe account data just to display the product list page (picture below).

In this design, the client application is playing the role of API composer. It invokes multiple services and combine the results. So, what’s the problem????Although the approach seems reasonable, it has some serious problems.

Poor User Experience Due To The Client Making Multiple Requests

The client must make multiple requests to retrieve the data and the client need to execute requests sequentially. It requires the client developer to write potentially complex API composition code.

Lack Of Encapsulation

The developer of a service sometimes add new services and might even change the API. But if knowledge about the service is composed in the client side, it can be difficult to change the service’s API and maybe can breaks existing client.

Unfriendly Protocol for The Client

Some of service might use gRPC, or maybe AMQP messaging protocol. These kind protocol work well internally, but might not be easily consume by mobile client. Or maybe the mechanism of some protocol might be hard to adapt in some client platform.

Solution

How to design and create an API gateway?I will discuss it in the part 2

Thank You

Again I would say thanks to all my readers and I hope I will comeback with more interesting topic.