Getting started with API gateways

Getting started with API gateways

What is an API gateway?

An API gateway acts as a "front door" for applications to access data, business logic, or functionality from your backend services.

It is software that takes an application user’s request and routes it to one or more backend services, gathers the appropriate data, and delivers it to the user in a single and combined package. It also provides analytics, layers of threat protection, and other security for the application.

Need for the API gateways?

Earlier, we used monolithic architecture to create web applications. Here we combined all our applications codes in a single monolith. So, the different client applications will send requests to the monolith. But with this monolithic architecture scaling our application was not easy, and it also included many other complex issues. The below diagram shows the architecture of the monolithic web application.

Monolithic web application

Then we implemented our applications using the microservices architecture. Here the application is deployed as a collection of independent multiple services. Here the different client applications will communicate with each application services separately. This helps each team to work independently on one particular service. This also leads to a lot of complexity because your client application has to send requests to multiple backend services to get the data it actually wants.

To solve this issue, we started using API gateways. So, instead of client applications communicating with multiple backend services, the client application communicates with the API gateway only. So, the API gateway acts as a single entry point to the main application.

Examples of popular API gateways are Apache APISIX and Kong.

Functions provided by the API gateways

  • Authentication and security policy enforcement

  • Load balancing and circuit breaking

  • protocol translation and service discovery

  • monitoring, logging, analytics, and billing

  • caching

References:

  1. What is an API gateway? (ByteByteGO)

  2. Getting started with apache APISIX (Navendu pottekkatt)