API Gateway
Route client requests through a shared entry point with clear boundaries.
system design, api gateway, routingOne front door
An API gateway is a service-facing entry point that can route requests and apply shared policies. It is not the same as a load balancer: a gateway may route by API path or apply authentication while a load balancer distributes traffic among instances. Products may combine these functions.
School app
- The school app sends a timetable request to the gateway.
- The gateway checks the configured credentials and routes the request to the timetable service.
- The service checks that the caller may see the requested timetable and returns a response through the gateway.
See the reasoning
Follow the example one step at a time
Follow a timetable request through a gateway and service. This is a prepared teaching demonstration, not live code execution.
Request
school app → gateway: timetable request
The app calls the shared entry point.
Store catalogue and checkout
A hypothetical store routes /catalogue to catalogue and /checkout to
checkout. Their policies and timeouts may differ. The gateway should not log
payment secrets; checkout still enforces its own authorization and validation.
Routing a request is not a guarantee that the destination will succeed.
Trade-offs and failure
Central policies can simplify clients but add latency, configuration and a shared failure point. Scale and monitor the gateway, define timeouts, and protect internal service boundaries. For a small system direct service access may be simpler. Avoid turning the gateway into a tightly coupled home for all business logic.
Reflect on the concept
Four fixed questions to reinforce the reasoning. Answers are not saved or scored.
