Tutorials System Design Mastery
API Gateways: Authentication, Rate Limiting, and Routing
On this page
The API Gateway
In a microservices architecture, you don't want the client talking to 50 different services. The API Gateway provides a single entry point that handles all the "Cross-Cutting" concerns.
1. Core Responsibilities
- Routing: Send
/usersto the User Service and/ordersto the Order Service. - Authentication: Verify the JWT once at the gateway so individual services don't have to.
- Rate Limiting: Block users who are making too many requests (DDoS protection).
2. Request Aggregation
The gateway can fetch data from 3 different services in parallel and combine them into a single JSON response for the client. This reduces the number of round-trips for the user's mobile device.
4. Interview Mastery
Q: "What is 'Backends for Frontends' (BFF)?"
Architect Answer: "BFF is an extension of the Gateway pattern. Instead of one giant gateway for everyone, you have a specific tiny gateway for **Web**, another for **Mobile**, and another for **Public APIs**. This allows the Mobile gateway to return smaller, optimized JSON payloads while the Web gateway returns full metadata. It prevents the 'One size fits none' problem of a single global gateway."
Sign in to ask a question or upvote helpful answers.
No questions yet — be the first to ask!