Check at the gateway
The gateway authenticates the API key, maps the route to an endpoint group, and then asks the limiter before the backend service does work. Sign-in is checked at the same point, but by IP and target account because there is no API key yet. Service-owned limits can still exist for facts the gateway cannot know, such as rows exported by a job.
- A request reaches the gateway with an API key, except sign-in.
- The gateway resolves the customer, plan and endpoint group from its local policy snapshot.
- It asks the limiter for every applicable policy.
- Only an allowed request reaches the backend service.
Diagram as text
Components: Client (Client); Authenticate key (Auth); Gateway check (API gateway); Limiter (Rate limiter); API service (Service); Sign-in request (Client). Connections: Client → Authenticate key (API key); Authenticate key → Gateway check (customer + plan); Gateway check → Limiter (policies to check); Gateway check → API service (only if allowed); Sign-in request → Gateway check (IP + account).
Read:Learn: API GatewayLearn: High-level architecture
Check yourself
Why not let each backend service add its own limiter?
Show answerHide answer
Then requests do work before they are refused, every service reimplements the rule, and a cross-service customer allowance is hard to enforce consistently.