Understanding how API Gateway Works

*warning — please drink coffee for better experience*


API Gateway series list


Imagine you are building an online store. Your application feature:

  • Order
  • Product Detail
  • List of Product

Based on all of feature above you have these service:

  • Product Service
  • Order Service
  • Pricing Service
  • Account Service
  • Customer Review Service
  • Inventory Service

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).

Consequently, the code that display the product list needs to fetch information from Product Service, Account Service, Customer Review Service, and Inventory Service.

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.

Easyread

Easy read, easy understanding. A good writing is a writing that can be understood in easy ways

Jonathan Natanael Siahaan

Written by

Easyread

Easyread

Easy read, easy understanding. A good writing is a writing that can be understood in easy ways

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade