API Gateway Design
You'll learn to
- -List what belongs at an API gateway (authentication, limits, routing, translation, observability) and what does not
- -Watch a gateway reject a bad token once, route a good request, and translate REST into an internal call
- -Explain why a gateway needs its own resilience, since all traffic passes through it
This module moves from designing one protocol to designing systems that combine several. It starts with the API gateway: the single entry point between outside clients and a system's internal services. It handles everything that would otherwise have to be repeated in every service.
An Analogy: The Reception Desk
A large office building has one reception desk. Visitors show ID there once, are told which floor to go to, and are logged in a book. The offices upstairs do not each need their own guard. But the desk is also a bottleneck and a single point of failure: if it closes, nobody gets in. A gateway is that desk for an API.
What Belongs at the Gateway
- -Authentication: check the caller's identity once, at the edge, instead of every internal service re-implementing token checks.
- -Rate limiting: enforce limits centrally, because a limit inside one service cannot see a client's total volume across all the services it calls.
- -Request routing: send each request to the right backend service by path, header or other rule.
- -Protocol translation: accept one protocol at the edge (REST, GraphQL) and translate to what internal services speak, often gRPC for the performance reasons from the gRPC modules.
- -Cross-cutting observability: logs, metrics and traces in one consistent place for every request, whichever service handles it.
What Does NOT Belong at the Gateway
Business logic, meaning the real rules for orders, payments or inventory, belongs in the services that own those domains. A gateway that collects business logic becomes a shared bottleneck that every team's changes must pass through. That is the coordination problem schema federation solved for GraphQL. Keeping the gateway to cross-cutting, protocol-level work keeps it from becoming that bottleneck.
Protocol Translation in Practice
GET /api/orders/501
Authorization: Bearer eyJhbGc...// The gateway authenticates the REST request, then calls the internal
// OrderService via gRPC on the client's behalf:
service OrderService {
rpc GetOrder (GetOrderRequest) returns (Order);
}
// gateway maps: GET /api/orders/{id} -> GetOrder(GetOrderRequest{id: id})
// and maps the protobuf Order response back to a JSON body for the clientThis lets internal services use gRPC's speed and strong typing for service-to-service calls, while outside clients still get the REST or GraphQL interface they need. The gateway is the one place that bridges the two worlds, so no internal service has to speak several protocols. The demo is a miniature gateway. It checks the token, finds the route, calls a service that knows nothing about HTTP, and turns the answer back into JSON.
A gateway is a single point of failure by design. It needs its own resilience story, meaning redundancy, health checks and graceful degradation, in proportion to how much traffic depends on it. An outage here affects every client of every service behind it.
Interview Signal is part of Pro
See a real weak answer next to a real strong one for this exact topic.
Quiz is part of Pro
Test what you just read with a short quiz, and bank the XP.
Design Gateway Architect in the API Design Lab's Full System Design act.
Discussion0
Join the Discussion
Sign in to leave comments, reply to others, or like insights.
No comments yet. Be the first to start the thread!