An API Gateway is the single entry point that sits in front of a microservices system, routing client requests to the right service and handling shared concerns for all of them.
Key Points: • It routes incoming requests to the correct backend service based on the URL path, host, or other request attributes. • It centralizes cross-cutting concerns like authentication, authorization, and rate limiting instead of duplicating them in every service. • It can improve performance by handling tasks common to all requests, such as TLS termination and response caching. • It simplifies the client's view of the system, since clients call one address instead of tracking every service's location. • Popular implementations include Spring Cloud Gateway, Netflix Zuul, Kong, and cloud-native gateways like AWS API Gateway.
Example: A mobile client sends every request to api.example.com, and the API Gateway forwards /orders/* to the Order service and /users/* to the User service, while enforcing a JWT check and a rate limit on every request before it's routed anywhere.
Interview Tip: A concise interview answer is:
"An API Gateway is the single front door to a microservices system: it routes requests to the right service and centralizes cross-cutting concerns like authentication, rate limiting, and TLS termination. It simplifies things for clients, who only need to know one endpoint, and keeps that shared logic out of every individual service."