LeetDesign
← All problems
Hard

Design an API Gateway

Authorize 350,000 API calls a second, then prove you still can with a third of every tier gone. The problem where 'handles peak' and 'survives an AZ loss' are different sums — and the grader runs both.

Design the front door of a cloud platform: every API call any customer makes, to any product, hits the gateway first — an authorization lookup that validates the API key and returns its routing, quota, and plan metadata — and completed calls batch usage records back for billing.

The volume is the first thing you notice: hundreds of thousands of authorizations a second, mercifully cacheable, because key metadata barely changes and a minute of staleness is the bargain every gateway makes. The shape is the second thing, and it is the one that will actually size your fleet: your callers are other people's servers, and machines do not sleep. The overnight floor still carries about seventy percent of the peak — and the contract demands every SLO hold through the loss of a full availability zone at that load. One dark zone takes a third of every tier with it, so a fleet that clears the peak with room to spare can still be arithmetically short the moment the replay starts.

No single component here is exotic. The difficulty is that the capacity arithmetic has to be right in four places at once, twice each: once at peak with the fleet whole, once at steady with a zone gone.