← All problems
Dashboard
Courses
Problems
Badges
Theme
Sign inStart free
Problem 031 · APIs and application architecture

Design an API Gateway Platform

Medium 50 min

A company has grown to 40 microservices, each exposing its own public endpoint with its own authentication code, rate limits and logging. Security reviews keep finding gaps and partners complain about inconsistent behaviour. Design an API gateway platform that becomes the single entry point for web, mobile and partner traffic: it authenticates callers, applies rate limits per API key, routes to the right service, blocks malicious traffic and gives every team the same logs and metrics. Peak traffic is 30,000 requests per second.

Functional requirements

  • Route requests to the right service by host and path, with versioned routes
  • Authenticate users (tokens) and partners (API keys) before requests reach services
  • Apply rate limits and quotas per API key and per user
  • Block common attacks and abusive traffic at the edge
  • Emit logs, metrics and trace IDs for every request

Non-functional requirements

  • Adds under 10 ms at p95 to each request
  • No single point of failure: losing a gateway instance causes no errors
  • Teams change their own routes without redeploying the gateway

Constraints and scale

  • 40 services owned by 12 teams
  • Peak of 30,000 requests per second, expected to double within a year
  • 2,000 partner API keys with different quotas

You will practise

  • Centralise cross-cutting concerns (auth, limits, logging) at the edge
  • Keep the gateway stateless and fast by caching tokens, keys and limits
  • Plan capacity with N+1 redundancy for a component every request passes through
Show 2 hints
  1. Every request passes through the gateway. What does that mean for how many instances you need when one fails?
  2. Calling an auth service on every request adds a hop. What could the gateway verify locally?

Ready to build?

Open the canvas, place your components and explain your decisions. Your draft saves automatically.

Sign in to start

Failure scenarios

  • A leaked partner key floods the APIA partner's API key is published on a public code site and a bot starts sending 15,000 requests per second with it.

Run them from the workspace once your design is in place.