An API gateway takes all API connections from clients and routes them to the specific microservice with request routing, data and protocol translation. Commonly it takes or handles a request by invoking many microservices and collect the results, to determine the best path. Can translate between web protocols and web-unfriendly protocols that are used internally.
What Is the Role?
This type of mechanism is the conductor that organizes the request being processed by the microservices architecture to create simplified experience for the user. Simply, it’s a translator, taking a client’s many requests and turning them into just one, to reduce the number of round trips between the client an application. An API gateway is set up in fron of the microservices and becomes the entry point for every new request being executed by the app. It simplifies both the client implementations and the microservices app.
For example, an ecommerce site might use an API gateway to provide mobile clients with an endpoint for retreiving all product details with a one single request. It invokes various services, like product info and reviews, and combines the results.
For most microservices‑based applications, it makes sense to implement an API gateway, because it acts as a single entry point into a system. The API gateway is responsible for request routing, composition, and protocol translation, and can streamline the system. With an API gateway, each of the application’s clients gets a custom API. It handles some requests by simply routing them to the appropriate backend service, and handles others by invoking multiple backend services and aggregating the results. If there are failures in the backend services, the API gateway can mask them by returning cached or default data.
I found a great video on the official Nginx site you can find below.