Question presented to candidate:
"We are splitting our backend into a dozen services, and the mobile and web apps are starting to call all of them directly. What is an API gateway, what would you put in it, what would you keep out of it, and how does it differ from a plain load balancer?"
What a strong answer should cover:
Definition: a reverse proxy that is the single entry point for external API clients, applying cross-cutting concerns once instead of in every service
The pipeline: routing (path, host, version), authentication (validating tokens or keys), coarse authorisation, rate limiting / quotas, request and response transformation, TLS termination, logging and metrics
Aggregation and the Backend for Frontend (BFF) pattern: one call from a slow mobile network instead of many, with worked latency numbers
How it differs from a load balancer (L7 routing and policy vs spreading traffic) and from a service mesh (north-south vs east-west traffic)
Risks: single point of failure and extra hop, a "smart gateway" that accumulates business logic, and gateway timeouts and limits (for example, Amazon API Gateway defaults)
Clarifying questions expected:
Who are the clients β first-party apps, third-party developers, or both?
How many services and teams, and who will own the gateway configuration?
Code / implementation expected: Optional β describing the pipeline is enough; sketching a route table or a token-bucket check is a plus.
api-gateway
2
Try it yourself
Sketch your approach before you read the solution. That is what the interview tests.
Stuck? Get a hint.
A short nudge toward the approach. It will not give the answer away.
3
Solution
Target Audience: Beginners to system design β you know what an HTTP API is; no microservices background assumed.
Difficulty: Medium
Verified with: Node 22.22 and Python 3.12 (both print identical output).
How to read this doc: Every idea is explained in plain language first, then tagged with π Interview term: so you also learn the exact words an interviewer expects. Behaviour and latency numbers come from running the example; the Verified section quotes the full output.
1. Why This Even Matters β A Story First
A large office building has forty companies inside. Without a reception desk, every company has to put its own guard at its own door, each checking badges in its own way β some strictly, some not at all. Visitors wander the corridors looking for the right floor.
So the building puts one reception desk in the lobby. It checks every visitor ID once, tu
The solution is hidden so you can try first
13 min read Β· 12 sections
4
Read the code
An API gateway pipeline: routing, signed tokens, roles, per-caller rate limit, aggregation