KEMBAR78
API Gateway | PDF | Gateway (Telecommunications) | Computer Network
0% found this document useful (0 votes)
7 views4 pages

API Gateway

An API Gateway serves as a single entry point for client requests in a microservices architecture, managing routing, authentication, and protocol translation. It simplifies client-server communication by aggregating responses from multiple services into one and reduces the number of network calls needed. The Backend for Frontend (BFF) pattern allows for tailored API responses for different client types, ensuring efficient data handling and minimizing over-fetching or under-fetching issues.

Uploaded by

kamsjyo91
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views4 pages

API Gateway

An API Gateway serves as a single entry point for client requests in a microservices architecture, managing routing, authentication, and protocol translation. It simplifies client-server communication by aggregating responses from multiple services into one and reduces the number of network calls needed. The Backend for Frontend (BFF) pattern allows for tailored API responses for different client types, ensuring efficient data handling and minimizing over-fetching or under-fetching issues.

Uploaded by

kamsjyo91
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

1. What is an API Gateway and what problems does it solve in microservices?

An API Gateway is a server that acts as a single entry point for all client requests to a microservices-
based application.

It is positioned between the client and the backend services and manages tasks such as routing,
protocol translation, authentication, rate limiting, and more.

Problems it solves:

• Clients no longer need to know about the internal structure of microservices.

• Centralizes authentication, authorization, logging, and monitoring.

• Handles differences in protocols (e.g., HTTP/1.1, HTTP/2, WebSockets).

• Reduces number of network round-trips by aggregating multiple responses into one.

• Enables fine-grained control over which client accesses what service and how.

2. Why is an API Gateway needed when multiple services are involved?


In a microservices architecture, each service typically exposes its own fine-grained API. When a client
(such as a mobile app or browser) needs data from multiple services, several problems arise:

• Too many calls: Clients must make multiple network calls to multiple services.

• Protocol mismatch: Services may use internal protocols that clients cannot handle.

• Security complexity: Each service would have to implement its own auth logic.

• Service discovery: Clients must know where each service is hosted.

The API Gateway:

• Acts as a reverse proxy and handles routing the requests to appropriate microservices.

• Hides service topology from the clients.


• Consolidates responses from multiple services into a single payload.

• Abstracts dynamic service discovery and versioning.

3. How does the API Gateway simplify client-server communication?


An API Gateway decouples clients from microservices by handling:

• Routing requests to appropriate services.

• Aggregating responses from multiple services.

• Translating protocols (e.g., REST to gRPC or SOAP).

• Enforcing policies for rate limiting, quotas, and security.

Example:

For a product page, a client might need:

• Product details (from Product Service)

• Price (from Pricing Service)

• Reviews (from Review Service)

Instead of making 3 calls, the client sends 1 request to the API Gateway, which fetches all necessary
data and responds with a combined result.

4. What features are typically supported by an API Gateway?


Most API Gateways support a rich set of enterprise features:

Feature Purpose

Routing Directs requests to correct service based on path/method

Load Balancing Distributes traffic across multiple service instances

Authentication/Authorization Centralized security using OAuth2, JWT, API keys

Rate Limiting & Quotas Prevents abuse by limiting client requests

Caching Reduces load by serving repeated responses from memory

Protocol Translation Converts HTTP/JSON to gRPC, WebSocket, SOAP, etc.

Monitoring & Logging Tracks usage, errors, and latency

Versioning Supports multiple versions of an API simultaneously

SSL Termination Handles HTTPS at the gateway level


Feature Purpose

Static Content Delivery Serves images, JavaScript, etc., directly from gateway

5. How does the API Gateway reduce the number of round trips from client to backend?
Without an API Gateway:

• A client must send multiple HTTP requests to various services.

• This increases network latency, overhead, and battery usage (on mobile).

With an API Gateway:

• The client sends a single request.

• The gateway fans out the request to all relevant services, collects responses, and aggregates
them into one unified response.

Benefits:

• Reduces round trips and improves performance, especially over slow or unstable networks.

• Simplifies client logic — the client does not need to orchestrate multiple API calls.

6. What is meant by “Backend for Frontend (BFF)” pattern and how is it implemented?
Backend for Frontend (BFF) is a design pattern where each client type (web, mobile, TV) gets a
dedicated API layer that tailors responses to its needs.

Why BFF?

• Different clients have different data requirements, screen sizes, and bandwidth.

• A generic API may under-fetch or over-fetch data for different platforms.

• Logic for fetching and combining data from multiple services should not be duplicated in
every client.

Implementation:

• Build a separate BFF service for each client type.

• Each BFF interacts with the same backend microservices but shapes the response specific to
the client.

• The BFF is often deployed as part of or alongside the API Gateway.

Example: Netflix

• Netflix uses an API Gateway that hosts device-specific adapters.

• Each adapter talks to 6–7 microservices and tailors the response for devices like smart TVs,
Android, iOS, etc.

You might also like