| Users | System Changes |
|---|---|
| 100 users | Direct service calls; simple routing; minimal latency; no gateway needed |
| 10,000 users | Multiple microservices; need unified access; increased request volume; API gateway introduced for routing and security |
| 1,000,000 users | High concurrency; gateway handles load balancing, authentication, rate limiting; caching added; gateway scales horizontally |
| 100,000,000 users | Global distribution; multiple API gateway clusters; CDN integration; advanced traffic shaping; microservices sharded; gateway handles failover and analytics |
Why API gateways unify service access in Microservices - Scalability Evidence
Start learning this pattern below
Jump into concepts and practice - no test required
As user requests grow, the API gateway becomes the first bottleneck because it handles all incoming traffic to multiple microservices. It must route, authenticate, and apply policies for every request. Without scaling, the gateway's CPU, memory, or network bandwidth limits will cause increased latency and dropped requests.
- Horizontal Scaling: Add more gateway instances behind a load balancer to distribute traffic.
- Caching: Cache common responses at the gateway to reduce backend calls.
- Rate Limiting: Protect backend services by limiting requests per user or IP.
- Edge Deployment: Deploy gateways closer to users (regional clusters) to reduce latency.
- Offload SSL/TLS: Terminate encryption at the gateway to reduce backend load.
- Use CDN: For static content, reduce gateway load by serving from CDN.
- At 1M users, assuming 1 request per second each = 1M RPS total.
- One gateway instance handles ~5,000 RPS → need ~200 instances.
- Network bandwidth per gateway: 1 Gbps (~125 MB/s) can handle ~10,000 requests of 10 KB each per second.
- Storage at gateway is minimal (caching few GBs), but backend storage grows with data.
- Cost scales with number of gateway instances, bandwidth, and caching infrastructure.
Start by explaining the role of the API gateway in unifying access. Discuss how traffic growth impacts the gateway first. Identify bottlenecks like CPU, memory, and network. Propose scaling solutions like horizontal scaling and caching. Mention trade-offs and monitoring needs. Use clear examples and numbers to support your points.
Your API gateway handles 1,000 requests per second. Traffic grows 10x to 10,000 RPS. What do you do first and why?
Practice
Solution
Step 1: Understand the role of API gateways
API gateways act as a single point where clients send requests instead of calling multiple services directly.Step 2: Compare options with this role
Only To provide a single entry point for clients to access multiple services describes this single entry point role correctly. Other options describe unrelated or incorrect roles.Final Answer:
To provide a single entry point for clients to access multiple services -> Option AQuick Check:
API gateway = single entry point [OK]
- Thinking API gateway stores data
- Confusing API gateway with database
- Believing API gateway replaces microservices
Solution
Step 1: Identify API gateway responsibilities
API gateways route client requests to the correct microservice based on the request.Step 2: Evaluate each option
Routing client requests to appropriate microservices matches routing requests. Options B, C, and D describe unrelated or incorrect functions.Final Answer:
Routing client requests to appropriate microservices -> Option AQuick Check:
API gateway routes requests = A [OK]
- Assuming API gateway updates databases
- Confusing API gateway with load balancer
- Thinking API gateway runs all services
Solution
Step 1: Analyze the API gateway's role in combining responses
The API gateway collects data from multiple services and sends a single combined response to the client.Step 2: Understand the benefit for the client
This reduces client complexity and the number of requests it must make, matching It reduces the number of client requests and simplifies client logic.Final Answer:
It reduces the number of client requests and simplifies client logic -> Option BQuick Check:
API gateway combines data = fewer client requests [OK]
- Thinking client must merge data
- Believing requests increase with API gateway
- Assuming microservices stop internal communication
Solution
Step 1: Understand the role of API gateway in client access
The API gateway provides unified access and security features like authentication and rate limiting.Step 2: Analyze the effect of bypassing the gateway
Bypassing removes these benefits, causing clients to handle complexity and security themselves, matching Clients lose the benefits of unified access and security provided by the API gateway.Final Answer:
Clients lose the benefits of unified access and security provided by the API gateway -> Option DQuick Check:
Bypassing API gateway = lose unified access [OK]
- Assuming microservices merge responses automatically
- Thinking API gateway blocks all requests if bypassed
- Believing clients have fewer requests when bypassing
Solution
Step 1: List benefits of API gateways in large systems
They simplify client calls by unifying access, add security layers, route requests properly, and combine responses.Step 2: Compare options with these benefits
API gateways reduce client complexity, improve security, and enable request routing and response aggregation correctly lists these benefits. Options A, C, and D are incorrect or misleading.Final Answer:
API gateways reduce client complexity, improve security, and enable request routing and response aggregation -> Option CQuick Check:
API gateway benefits = B [OK]
- Thinking API gateway replaces microservices
- Believing clients cannot call multiple services without gateway
- Assuming API gateway always slows down requests
