The concept behind API Gateway

I am working in THALES GROUP as Software Engineer. And you can follow me here for my Technical Blog Posts in which i am sharing my knowledge with the hashnode community.
Search for a command to run...

I am working in THALES GROUP as Software Engineer. And you can follow me here for my Technical Blog Posts in which i am sharing my knowledge with the hashnode community.
No comments yet. Be the first to comment.
In this Series, I will be creating blogs describing the Microservice and it's components.
After coming to the field of development, developers surely heard about the term monolithic and microservice. But we are not getting a proper resource to understand it in depth. Basically, this term always comes in the path of frontend and backend de...
I want to welcome you all with one more knowledge gain topic. We know how fast NodeJS get attention towards developers. Now, the Developer suggests NodeJs because of its power. So, Do you know what's the power of NodeJs? I think you should know if yo...

Hello 👋, I am again here with the most requested topic How to get a job as a developer if you don't have a CS background. So, I think I can write to help some readers so, they can start their career as the developer. I will be explaining the ways th...

First of all a very welcome 🙏 to all of my readers. In this blog, I'll be describing what is AWS Lambda Function which is also termed as Serverless Function based on FaaS (Function as a Service) Architecture, and How it is different from our Traditi...

when we are developing a project then architecture will be going to take an important part in the whole development journey. So, I think no developer wants to ruin their night in the office for the late release pressure. And sometimes the company fac...

Once again I am here with an informative topic of microservice which is required to understand. We definitely need to know the purpose of API Gateway in the microservice world. And I am sure after reading this blog you will know everything about API Gateway.

When we are developing our microservice then we need to come up with an architecture in which communication will be done easily, having loosely coupled services and one trusted medium to connect with the world. API Gateway is used for so many reasons which I will be explaining one by one.
API Gateway is a server that sits between the client and our collection of the backend server. And it is the single source of trust for the backend for consuming client requests. Somewhat it acts as a reverse proxy but with more other use cases.
API Gateway is used for many reasons which are listed below:-
SSL Offloading is a process in which we remove the SSL-based encryption for further communication in the channel. Like you can see in the above image client request which is coming to API Gateway is SSL based like https:// but after being authenticated by API Gateway all the requests to the backend server may or may not be SSL based. SSL Offloading depends based on use cases.
When we need to communicate with the backend server which is on the local network of API Gateway then there is no need to again send SSL-based requests to the Backend Server. But if the backend server is not on the local network then we need to use SSL encryption for further communication.
By using API Gateway, we can restrict the direct communication of clients to the backend server. This means we can only going to trust the request which is sent or forward by API Gateway otherwise we can deny the request if that request coming from the client directly. And API Gateway also hides many things which are listed below:-
API Gateway hides the complex microservice-based implementation. And it helps the developer as a security mechanism also.
When we are developing microservice architecture then we must have to log all request and error log somewhere. Which also helps in debugging critical issues and also for developing analytics boards. So, for that purpose, we can put the logger at the API Gateway which is the entry point for the outside world. Logging at API Gateway gives the Centralized way to log requests and errors.
Caching APIs take an important role in the fast API response for slow and calculation-based APIs. And when we are developing some dashboard that uses slow API which always returns similar responses then we can cache that API to the API Gateway which also helps in a fast response. And when we put it at the API Gateway then we can cache in a single place otherwise we need to put caching databases like Redis on each backend server.
When we are creating access-based APIs then we need to authenticate the user for accessing the resources. So, Here we can directly place the authentication server as a middleware which basically authenticates all incoming requests from the client, and then if the access for the user is present in that case we create a call to the resource server for fulfilling the API request. Now, it looks satisfying that API Gateway takes an important role in microservice-based architecture development.
When we are developing restriction-based API then we don’t want to duplicate the logic for rate limit on every backend server. In the case of API Gateway, we can limit the use of API as a centralized logic for all backend servers. So, for that purpose, we can create an adapter kind of pattern that basically checks a particular API/every API which is according to development need.
When it comes to versioning APIs then versioning is a headache for the developers that how they will going to versioning their development, staging, QA, production deployment. Then API Gateway comes to the rescue and filling the gap for versioning APIs. Basically, we can Authenticate or route our different platform users to different servers like development, staging, production based on the interacting URL of the user. Example – for http://staging.api.com to a staging server, for http://qa.api.com to the QA server, for http://development.api.com to the development server.
While creating the complex aggregation which requires data from multiple backend servers then we can compose API which is basically the aggregation of responses of one or many backend servers into a single composite response.
In Simple words, we are aggregating two or more responses into a single API response.
After understanding all these functionalities now we know what is API Gateway.
There are many API Gateway services and open source projects which developers can use
And there are many more which developers can use for the API Gateway otherwise developers can also create their own service which works as API Gateway.