CMD Guide
HomeSystem DesignAPI Gateway

Advantages and disadvantages of using API gateway

Advantages of an API gateway

An API gateway sits in front of your backend services as the single entry point for client traffic. Centralizing cross-cutting concerns there — rather than repeating them in every service — is the whole value proposition. The main benefits:

Disadvantages of an API gateway

None of this is free. The same chokepoint that gives you leverage also concentrates risk:

The trade-off in one line: an API gateway exchanges a small, well-understood amount of latency and operational surface for a large reduction in duplicated cross-cutting logic across services. That trade is usually worth it once you have more than a handful of backend services or an external API surface — and usually not worth it for a single monolith with no external clients.

Make the tension concrete with a fleet of 40 services. Pulling authentication into the gateway means one JWT-verification library to patch and re-audit instead of 40 — a real, countable win. The same centralization is the liability: one bad config push can page all 40 teams at once, where before a bug was contained to the one service that shipped it. That is why gateway config deserves the same discipline as application code — progressive/canary rollout of route changes and per-route synthetic probes — so a single edit cannot floor the whole fleet.

Worked example: where does the latency actually go?

"The gateway adds latency" is true but vague. Here is a concrete breakdown for one request that misses the gateway's response cache and has to travel all the way to the backend:

Latency budget for one request that misses the gateway's cache
StageWhereTime (ms)
TLS session resumptionGateway0.2
JWT verificationGateway0.5
Rate-limit check (Redis round trip)Gateway0.6
Cache lookup (miss)Gateway0.1
Response marshaling back to clientGateway0.4
Gateway subtotal1.8
Network hop + connection setup to backendNetwork2.0
Backend request processingBackend service30.8
End-to-end total34.6
diagram
diagram

Reading the numbers

Summing the five gateway-side steps — TLS session resumption (0.2 ms), JWT verification (0.5 ms), the rate-limit check (0.6 ms), the cache-miss lookup (0.1 ms), and marshaling the response back to the client (0.4 ms) — gives 1.8 ms of gateway-owned time. Against the 34.6 ms end-to-end total, that is 1.8 / 34.6 ≈ 5.2%, closer to "1 in 20 ms" than "1 in 16." The remaining ~94.8% is network transit and backend processing, which the gateway neither caused nor can optimize away.

The practical implication: on a cache miss, optimizing the gateway itself has a low ceiling. If p99 latency is a problem, profile the backend and the network path first — shaving the gateway's 1.8 ms is diminishing returns next to a 30.8 ms backend call.

Pitfalls to watch for in production

Beyond the textbook disadvantages above, a few failure modes only show up once a gateway is carrying real traffic:

Drill: defend the gateway against a plain ALB

Design-review follow-up: "We have three services. Why an API gateway at all — why not a plain ALB with path-based routing?"

Answer sketch. Start by conceding what the ALB already gives you: TLS termination, path/host-based routing to target groups, health checks, and replica load balancing — for less money and near-zero operational surface. A gateway earns its keep only for the concerns the ALB does not carry: token validation, per-client quotas/rate limits, request/response transformation, and API versioning. The real test is duplication: if each of the three services would otherwise re-implement JWT verification and rate limiting itself, the gateway replaces three copies of that logic (three libraries to patch, three configs to audit) with one. If the three services share no such cross-cutting logic — or it already lives in a shared middleware library — the honest answer is that the ALB wins today, and the gateway is a decision to revisit when the service count or the duplicated edge logic grows.

Sources

Original lesson: "Advantages and disadvantages of using API gateway" — Knowledge Guide, System Design → API Gateway. The latency figures above are an illustrative worked example rather than a measurement from one specific vendor; the order of magnitude for TLS session resumption, JWT verification, and a Redis-backed rate-limit check is consistent with published gateway benchmarks from AWS API Gateway, Kong, and NGINX. The production pitfalls (retry storms, request fan-out, request/response body buffering) draw on Sam Newman, Building Microservices, 2nd ed. (O'Reilly, 2021), and standard reverse-proxy operational guidance from the NGINX and Envoy documentation.

🤖 Don't fully get this? Learn it with Claude

Stuck on Advantages and disadvantages of using API gateway? Open Claude, copy a block below, and it'll teach you this exact concept — visually and interactively.

🎨 Explain it visually

Build the mental picture, not memorization.

I just read a lesson on **Advantages and disadvantages of using API gateway** (System Design) and want to truly understand it. Explain Advantages and disadvantages of using API gateway from first principles using ONE vivid real-world analogy and a visual mental model — draw it as ASCII art or a clear step-by-step diagram — with a concrete example using real numbers. Then ask me one question to check I got the mental picture, and wait for my reply. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🤔 Walk me through it (interactive)

Socratic — adapts to where you're stuck.

Teach me **Advantages and disadvantages of using API gateway** interactively. Ask me ONE guiding question at a time, wait for my answer, and adapt to my confusion — build the idea with me step by step instead of explaining it all at once. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧪 Quiz me & fix my gaps

Active recall exposes what you missed.

Quiz me on **Advantages and disadvantages of using API gateway** with 5 questions, easy to tricky, ONE at a time. Tell me if each answer is right; at the end, explain clearly what I got wrong and why. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧠 Make it stick

Intuition + hook + flashcards for long-term memory.

Help me remember **Advantages and disadvantages of using API gateway** for the long term: give the one-sentence intuition, a memorable hook/mnemonic, a tiny worked example, and 3 active-recall flashcards (Q -> A). If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.

📝 My notes