May we use cookies so Meta, Google, LinkedIn and ChatGPT see your visit and we learn which ads work? PrivacyMay we use cookies to see which pages help, and let Meta, Google, LinkedIn and ChatGPT see your visit, so we know which of our ads work? That way we spend less on ads that do not work. We do not sell your data, and the site works the same if you decline. You can change your answer at any time under Cookie settings at the foot of the page. Privacy policy
Loading...
System Design and AI Engineering, by Roni Das. 989 interactive lessons in two courses.: 770 in System Design and 219 in AI Engineering.
Start LearningSystem design interview guide
in this guide
7 parts open to everyone · 3 with a free account · 3 with the course
You can read 7 of 13 parts. A free account opens the deep dive; the course opens all of it.
Interviewers like this problem because it forces a candidate to separate cross-cutting concerns from business logic, which is the central skill in microservices design. It tests whether you understand the request lifecycle in depth: TLS termination, authentication, authorization, rate limiting, routing, transformation, and observability, and in what order they must run. It also probes reliability thinking, because the gateway is a shared dependency for every team, so a candidate has to reason about how to keep one bad plugin or one slow upstream from taking down the whole front door. Finally it reveals judgment about scope. A weak answer piles orchestration, retries with business meaning, and data joins into the gateway. A strong answer keeps it thin and pushes ownership to the services.
This page is the free part.
₹1,111 in India$35 everywhere elseonce, for the whole course
The System Design course covers the API Gateway design across a run of lessons, not one page. These 4 alone are about 103 minutes of step-by-step reading, every one with a quiz.
Always clarify these in the first 5 minutes of the interview. Do not start drawing boxes until both lists are agreed.
This guide is built on these 5 lessons. Each one teaches one piece of the API Gateway design above, step by step.
Lifetime access for ₹1,111 in India or $35 elsewhere. Interactive diagrams, quizzes, and 20 capstone projects to practise on.
This one question is not enough for the interview.
Each question has why it is asked, a full answer, what the interviewer listens for, the follow-ups, the common mistakes and a diagram (268 diagrams in all). A PDF you keep, junior to staff level.
Two courses by the author of this page:
770 lessons · 18 free to read
₹1,111 in India · $35 elsewhere, once
Get System DesignYou own this course
219 lessons · 10 free to read
₹1,333 in India · $35 elsewhere, once
Get Generative AI and Agentic AIYou own this course
Save your progress and get the interview checklist PDF
When you split a monolith into two hundred services, every client suddenly needs to know where each service lives, how to authenticate to it, and how to retry it. An API gateway collapses that into one address. Netflix's Zuul gateway fleet handles more than one million requests per second across roughly 80 clusters, fronting about 100 backend service clusters (Netflix engineering, estimates vary by year). The gateway is the busiest single tier in the whole architecture, so its design decisions ripple through everything behind it.
An API gateway is the single entry point that sits between external clients and a fleet of internal microservices. It terminates TLS, authenticates and authorizes each request, applies rate limits and quotas, routes to the correct upstream based on path or host or headers, and often transforms or aggregates responses before returning them. The hard part is that it is on the critical path for every request, so it must be fast, non-blocking, and horizontally scalable without becoming a single point of failure. Good designs treat the gateway as a thin, stateless, policy-enforcing proxy built around a chain of composable filters or plugins, with heavy work (business logic, data ownership) pushed back into the services. The interview is really about where responsibility belongs: what the gateway should own versus what it must never own. Candidates who put too much logic in the gateway rebuild a distributed monolith with a new name. The reference implementations to reason from are Netflix Zuul 2, Kong, Envoy, and AWS API Gateway, each of which models the request lifecycle as an ordered set of pluggable stages.
Where it shows up
Asked at Amazon, Netflix, Uber, Stripe, Atlassian, and most companies running a microservices or platform team. It shows up both as a standalone gateway design and as a component inside larger designs like 'design Uber' or 'design a payments platform'.
Spec sheetAPI Gateway
worked through below, with the maths
The hard parts of this design are taught step by step in the System Design course: Reverse Proxy, Rate Limiting and Backend for Frontend (BFF).
An intermediary that receives requests on behalf of servers, for TLS, routing, balancing, caching and protection.
Protect your API from abuse and overload by controlling how many requests each consumer can make.
A dedicated backend for each frontend, tailor your API to each client's needs.
A dedicated infrastructure layer for managing service-to-service communication, observability, security, and traffic control without changing application code.
all part of
System Design Masterclass
770 lessons · about 290 hours · 18 free to read
₹1,111in India, by UPI
$35everywhere else, by card or PayPal
You own this course
Continue with Reverse Proxypay once,
yours for life
Live from the course bench
Real interview questions, live diagrams and measured lab results, pulled at random from the lessons. A new set every time you come back.
Show your math. Pulling numbers from thin air signals you have not thought about the load.
Peak request rate (large gateway fleet)
~1,000,000+ requests/sec
Netflix has publicly described its Zuul fleet handling over 1M req/sec across roughly 80 clusters. This is a real published figure for a very large deployment, not typical. Most gateways serve far less.
Per-instance throughput
~5,000 to 20,000 req/sec
Derived estimate. A non-blocking Netty or Nginx-based gateway on a modern 8-core instance commonly sustains low tens of thousands of simple proxy requests per second. To serve 1M req/sec at ~10k per instance you need ~100 instances, matching the order of magnitude of large fleets.
Added latency budget (p50)
~1 to 5 ms
Estimate based on a thin proxy path. TLS is already terminated per connection, so per-request overhead is header parsing, an auth token check (often a cached lookup), a rate-limit counter read, and route selection. Each is sub-millisecond when backed by in-memory or Redis lookups.
AWS API Gateway account throttle (default)
10,000 req/sec, 5,000 burst
Published AWS default account-level throttle per Region, using a token bucket. Some newer Regions default to 2,500 req/sec with 1,250 burst. These are managed-service ceilings you would design around, not build.
Rate-limit counter operations
~1 to 3 Redis ops per request
Derived. A token-bucket or sliding-window limiter typically does one atomic increment plus an occasional refill read. At 1M req/sec that is roughly 1 to 3M Redis ops/sec, which forces sharding the counter store by key rather than a single node.
Route table size
hundreds to low thousands of routes
Estimate. One route per public API surface across ~100 to a few hundred services, with a handful of paths each. This fits comfortably in memory as a compiled trie or radix tree, so route matching is not the bottleneck.
A client resolves one DNS name and connects to a layer 4 or layer 7 load balancer, which spreads connections across a pool of stateless gateway instances running in multiple availability zones. The gateway instance terminates TLS, then runs the request through an ordered chain of filters. Inbound filters parse and validate the request, authenticate the caller by verifying a JWT signature or looking up an API key, check authorization scopes, and apply rate limiting by reading and incrementing a counter in a shared store like Redis. If any of these reject the request, the gateway returns an error immediately and never touches a backend. If they pass, a routing filter matches the request against a compiled route table (path, host, method, headers) to pick a target service, then consults service discovery to get a healthy instance and applies a load-balancing policy. An endpoint filter proxies the request upstream using a non-blocking HTTP client, optionally rewriting the path, injecting the verified identity as a trusted header, and translating protocols. When the response returns, outbound filters run in reverse: they can strip internal headers, compress or reshape the body, add caching headers, and record metrics and traces. For aggregation or backend-for-frontend routes, a composition filter fans out several upstream calls concurrently and stitches the results into one response. Every stage emits logs, metrics, and a trace span so the whole path is observable. Configuration (routes, limits, plugin settings) is pushed dynamically from a control plane so instances reconfigure without restarts.
In a real interview, sketch this on the whiteboard before diving into any single box.
Walk through each service. The interviewer wants to hear what each one owns, not just the names.
A layer 4 or layer 7 balancer distributes client connections across gateway instances and removes unhealthy ones from rotation. It is what makes the gateway itself horizontally scalable and free of a single point of failure. The gateway is deliberately stateless so any instance can serve any request.
The gateway terminates client TLS once per connection and reuses that connection for many requests via keep-alive. It presents a single certificate and hostname to the outside world while the internal topology stays hidden. Non-blocking I/O (Netty in Zuul 2, Nginx event loop in Kong) lets one instance hold many thousands of concurrent connections cheaply.
The heart of the gateway is an ordered pipeline of small, composable filters that each own one concern: auth, rate limiting, routing, transformation, logging. Zuul calls them inbound, endpoint, and outbound filters; Kong calls them plugins that run in access, rewrite, header_filter, body_filter, and log phases; Envoy calls them HTTP filters in a decode and encode chain. New behavior is added by writing a filter, not by editing a monolith.
Verifies the caller's identity from an API key, JWT, OAuth2 token, or client certificate, then checks that the identity holds the scopes required for the route. It offloads this cross-cutting concern from every service so backends can trust a signed internal header. Token verification is usually a fast local signature check or a cached lookup rather than a database call on every request.
Enforces per-client, per-key, and per-route limits using algorithms like token bucket or sliding window, backed by a shared counter store so limits hold across all gateway instances. It protects upstreams from overload and abusive callers. Because counters are hot and shared, they are sharded by key and often use atomic operations in Redis.
Matches each request to a route using a compiled trie or radix tree over path, host, method, and headers, then resolves the target to a live instance via service discovery (Consul, Eureka, Kubernetes endpoints) rather than a hardcoded address. It applies a load-balancing policy and health awareness so traffic avoids dead instances. Route and endpoint data refresh dynamically as services scale up and down.
A control plane distributes route tables, rate-limit rules, and plugin configuration to every instance without restarts, so operators change behavior at runtime. Every request produces structured logs, latency and error metrics tagged by route, and a distributed trace span. This is what lets a platform team debug which upstream or which plugin is slow when the front door misbehaves.
routes. Defines how an incoming request maps to a backend. Loaded into memory as a compiled trie for fast matching. In managed gateways this is config, not a hot database read.
Every table for API Gateway, its keys, and which store fits it and why.
The request lifecycle and why filter order matters. A request flows through the gateway as an ordered pipeline, and the order is not arbitrary. Cheap rejections must come first so the gateway spends as little work as…
7 deep dives on the parts that break at scale: The request lifecycle and why filter order matters; Plugin and filter chain architecture (Zuul, Kong, Envoy); Rate limiting across a distributed gateway fleet.
Thin routing gateway versus fat orchestration gateway. A thin gateway (routing, auth, limits only) keeps teams decoupled and the front door fast and safe, at the cost of pushing aggregation into separate BFF layers. A fat…
6 decisions an interviewer expects you to defend, each with the alternative and why it loses here.
A new plugin release adds 200 milliseconds to every request. How do you limit the blast radius?
4 follow-up questions with model answers, the interview scorecard for this question, and a mock interview on Design API Gateway with the AI tutor.
Netflix Zuul is the most documented large-scale gateway. Zuul 1 was a blocking, thread-per-request system; Netflix rewrote it as Zuul 2 on Netty with inbound, endpoint, and outbound filters running asynchronously, and reported roughly a 25% throughput increase with a matching drop in CPU. Their gateway fleet has been described as handling over a million requests per second across dozens of clusters fronting around a hundred backend clusters. Kong is built on OpenResty (Nginx plus LuaJIT) and models everything as plugins that run in named phases (rewrite, access, header_filter, body_filter, log), with each plugin a handler.lua plus a schema.lua. Envoy, which powers Istio and many service meshes, structures processing as listeners, network filters, and an HTTP connection manager that holds an ordered chain of HTTP filters, invoking decoder filters in order and encoder filters in reverse. AWS API Gateway is the managed reference point, throttling with a token bucket at a default account level of 10,000 requests per second with a 5,000 burst per Region (lower in some newer Regions). Across all four, the common thread is the same: a thin, non-blocking, horizontally scaled proxy whose behavior is composed from an ordered chain of pluggable stages.
If any of these topics are fuzzy, the interviewer will catch it. Each lesson is 15 to 60 minutes with diagrams, code, and a quiz.
interview readiness
Three questions from this guide. Answer them without scrolling up, the way you would have to in the room.
Pay by UPI, cards or netbanking through Razorpay. Pay by card or PayPal, in US dollars. Download at once from My packs.
NEWSystem Design Hands-On
Postgres Sharding: Complete Hands-On (PgBouncer + Citus). 2 h 36 min and 20 chapters: one PostgreSQL loaded until it breaks, then four shards behind a router you write, PgBouncer and Citus, with the 139-page slide deck. The first 15 minutes are free to watch.
Free PDF · 79 pages
25 real tech interview questions, answered in full
Five from each of our AI, GenAI, Inference, Maths for ML and Forward Deployed packs. Each with a diagram and a model answer. Free by email.
free tool
Check these numbers yourself
Put in your own guesses for API Gateway and see requests per second, storage, bandwidth and servers, with every sum written out.
Open the Capacity EstimatorIt is really nice and good Please join the course