What is API Gateway ?

rakeshreddy512

Rakesh Reddy Peddamallu

Posted on August 29, 2024

What is API Gateway ?

Today we will go through another fundamental component of system design , API Gateway

Image description

  1. It is an intermediary between clients (website , mobile , services) and backend services or API's or microservices

  2. Its main purpose is to provide a single point entry for external consumers , requests will be forwarded to appropriate microservice by the API Gateway once the request it received , and once it get response from the server it is forwarded back to client to API Gateway

  3. API Gateway is responsible for routing , authentication and rate limiting , this enables microservices to focus on their business logic and leaving things like auth to happen at gateway level.

Difference between API Gateway and Load Balancer

  1. Loadbalancer distributes the load between backend servers so as to use the resources effectively , where as API gateway routes the requests to the appropriate microservice based on the request URL

Usage of API Gateway

Image description

API Gateways are used for various purposes in microservice architecture

Routing - Api Gateway routes the requests to appropriate microservice

RateLimiting and throttling - To prevent DDOS attacks , we can do ratelimiting or throttling at api gateway , It does this by limiting the number of requests that a single client or user can make within a certain period of time

Caching - we can cache some of responses at api gateway , so that it do not overwhelm the microservice

Authentication and Authorization - We can do the authentication and authorization at api gateway , so that microservices can focus on the business logic without worrying about authentication

Loadbalancing - API Gateway can be acted as loadbalancer as it distributes the requests between microservices

Monitoring - We can monitor the requests and responses at the API Gateway Level which gives insights about performance metrics of microservices

Transformation - API Gateway can transform the response formats to the formats needed by clients , it can also aggregate the responses from multiple microservices.

Service Discovery - The API gateway can discover available microservices dynamically, allowing clients to access services without needing to know their specific locations or addresses.

API Versioning - We can version the apis like v1 , v2 without impacting the existing clients through API Gateway.

Service Aggregation - API Gateway can aggregate the data from multiple backend services .

Web Application Firewall (WAF) - we can prevent the web attacks like XSS (cross site scripting) , sql injection etc by incorporating a web app firewall at api gateway

API Documentaion - API gateway can provide the documentation of APIs in a standard format like swagger or openAI

Advantages and Disadvantages of API Gateway

πŸ’– πŸ’ͺ πŸ™… 🚩
rakeshreddy512
Rakesh Reddy Peddamallu

Posted on August 29, 2024

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related