The API Gateway takes all the requests from the client, determines which services are needed, and combines them into a synchronous experience for the user.
What is an API Gateway?
The API Gateway takes all the requests from the clients, then routes them to the appropriate microservice with request routing, composition, and protocol translation. Typically it handles a request by invoking multiple microservices and aggregating the results, to determine the best path. It can translate between web protocols and web-unfriendly protocols that are used internally.
An API Gateway might be used on an ecommerce site, it provides an endpoint that enables a mobile client to retrieve all the product details with a single request. It invokes various services, like product info and reviews, and combines the results.
Videos on API Gateways
Building Microservices Using an API Gateway
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.
The Role of API Gateways in Microservice Architectures
An API Gateway is the conductor that organizes the requests being processed by the microservices architecture to create simplified experience for the user. The Gateway is a translator, who takes a client’s many requests and turns them into just one, to reduce the number of round trips between the client and application. An API Gateway is set up in front of the microservices and becomes the entry point for every new request being executed by the app. The Gateway simplifies both the client implementations and the microservices app.