- Published on
API Gateway vs Reverse Proxy - System Design Interview Guide
Table of Contents
- ?? 2. API Gateway (Deep but concise)
- ? What it does
- ?? Key Insight
- ??? Architecture Decision Signals (Use API Gateway when):
- ? When NOT to use
- ?? FAANG Interview Q&A
- ?? Script (Interview-ready)
- ?? 3. Reverse Proxy (Deep but concise)
- ? What it does
- ?? Key Insight
- ??? Architecture Decision Signals (Use Reverse Proxy when):
- ? When NOT to use
- ?? FAANG Interview Q&A
- ?? Script (Interview-ready)
- ?? 4. Key Differences (High-yield table)
- ?? Script
- ?? 5. Real Architecture (FAANG Style)
- ? Production Setup (VERY IMPORTANT)
- ?? Why BOTH?
- ?? FAANG Q&A
- ?? Script
- ?? 6. Strong Signal vs Weak Signal (IMPORTANT)
- ?? Choose API Gateway (Strong Signals)
- ?? Choose Reverse Proxy (Strong Signals)
- ?? Weak Signals (Don�t over-engineer)
- ?? 7. Extra FAANG-Level Insights (Added)
- ?? 1. BFF Pattern (Advanced)
- ?? 2. Service Mesh vs API Gateway
- ?? 3. CDN vs Reverse Proxy
- ?? Final Ultra-Short Summary
- API Gateway ? Application-level brain (microservices orchestrator)
- Reverse Proxy ? Network-level shield (traffic manager)
?? Script to memorize:
�API Gateway manages what happens inside the system. Reverse Proxy manages how traffic reaches the system.�
?? 2. API Gateway (Deep but concise)
? What it does
-
Single entry point for microservices
-
Routes requests to correct service
-
Aggregates multiple service responses
-
Handles:
- Auth (JWT, OAuth)
- Rate limiting
- Logging
-
Protocol translation (HTTP ? WebSocket, gRPC)
?? Key Insight
?? Works at L7 (application layer) with business awareness
??? Architecture Decision Signals (Use API Gateway when):
- You have microservices (10�1000 services)
- Client needs single unified API
- Need aggregation (1 request ? multiple services)
- Need fine-grained auth / rate limiting per API
- Need versioning (v1, v2 APIs)
? When NOT to use
- Simple monolith
- No need for aggregation/orchestration
- Adds latency (extra hop)
?? FAANG Interview Q&A
Q1: Why API Gateway in microservices? ?? Reduces client complexity + centralizes cross-cutting concerns.
Q2: What problem without it? ?? Client calls 10 services ? tight coupling + latency + complexity.
Q3: Drawback? ?? Single point of failure + latency + scaling complexity.
?? Script (Interview-ready)
�In a microservices system, I introduce an API Gateway as a single entry point. It handles authentication, rate limiting, and routes requests to appropriate services. It can also aggregate multiple service responses, reducing client complexity.�
?? 3. Reverse Proxy (Deep but concise)
? What it does
- Sits between client and servers
- Load balances traffic
- Caches responses
- SSL termination
- Hides backend servers
?? Key Insight
?? Works at L4/L7 but infra-focused (NOT business logic)
??? Architecture Decision Signals (Use Reverse Proxy when):
- High traffic ? need load balancing
- Need SSL offloading
- Need caching (static content)
- Want to hide backend IPs
- Need DDoS protection layer
? When NOT to use
- Very small system (overkill)
- No scaling/security concerns
?? FAANG Interview Q&A
Q1: Why reverse proxy instead of direct server access? ?? Adds security, load balancing, and caching.
Q2: Difference from load balancer? ?? Reverse proxy can act as load balancer but also adds caching + SSL + security.
Q3: Example tools? ?? Nginx, HAProxy, Envoy
?? Script (Interview-ready)
�I place a reverse proxy in front of servers to handle load balancing, SSL termination, and caching. It improves performance and hides backend infrastructure from clients.�
?? 4. Key Differences (High-yield table)
| Aspect | API Gateway | Reverse Proxy |
|---|---|---|
| Level | Application (L7) | Network/Infra |
| Purpose | Business logic routing | Traffic handling |
| Microservices aware | ? Yes | ? No |
| Aggregation | ? Yes | ? No |
| Auth / Rate limit | ? Advanced | ?? Basic |
| Load balancing | ?? Limited | ? Core feature |
| Caching | ?? Limited | ? Strong |
| Protocol translation | ? Yes | ? Rare |
?? Script
�API Gateway is application-aware and handles business routing, while Reverse Proxy focuses on infrastructure concerns like load balancing, caching, and security.�
?? 5. Real Architecture (FAANG Style)
? Production Setup (VERY IMPORTANT)
?? Both are used together
Client
?
Reverse Proxy (Nginx / CDN / WAF)
?
API Gateway (Kong / Apigee)
?
Microservices
?? Why BOTH?
- Reverse Proxy ? performance + security
- API Gateway ? business logic + orchestration
?? FAANG Q&A
Q: Why not only API Gateway? ?? It�s expensive + not optimized for caching/load balancing.
Q: Why not only Reverse Proxy? ?? No business logic, no aggregation.
?? Script
�In scalable systems, we combine both. Reverse proxy handles traffic optimization and security, while API Gateway manages application-level routing and orchestration.�
?? 6. Strong Signal vs Weak Signal (IMPORTANT)
?? Choose API Gateway (Strong Signals)
- �Microservices�
- �Aggregation needed�
- �Different clients (mobile/web)�
- �Auth per API�
- �API versioning�
?? Choose Reverse Proxy (Strong Signals)
- �High traffic�
- �Latency optimization�
- �Caching required�
- �SSL termination�
- �DDoS protection�
?? Weak Signals (Don�t over-engineer)
- Small app ? No need for API Gateway
- Low traffic ? No need for reverse proxy
?? 7. Extra FAANG-Level Insights (Added)
?? 1. BFF Pattern (Advanced)
- Backend-for-Frontend ? multiple API Gateways for different clients
?? 2. Service Mesh vs API Gateway
- API Gateway ? north-south traffic
- Service Mesh ? east-west traffic
?? 3. CDN vs Reverse Proxy
- CDN = global reverse proxy with edge caching
?? Final Ultra-Short Summary
?? Golden line (memorize this):
�Reverse Proxy optimizes and protects traffic. API Gateway understands and orchestrates APIs.�