Identify how a gateway becomes a performance bottleneck, an organisational coupling point and a single point of failure, quantify its latency and capacity overhead, design highly available and blast-radius-limited gateway deployments, govern gateway configuration safely, and apply a thin-gateway architecture
Because all traffic flows through it, the gateway concentrates risk. The TOC names three:
Figure 1 — Gateway risks and controls
TOC risk
Definition
Bottleneck
The gateway limits throughput or adds latency (CPU, connections, synchronous work, shared state)
Coupling
Teams and services depend on the gateway for changes — logic and configuration centralised in one component owned by one team
Centralized failure
A gateway outage or bad configuration makes every API unavailable (single point of failure, huge blast radius)
Table 1 — Gateway risks
2Why It Exists
Every centralisation trades autonomy and resilience for consistency. The enterprise service bus (ESB) era showed what happens when integration logic accumulates in a central component: bottlenecks, change queues and fragile deployments. API gateways can repeat that history unless architects consciously limit their scope and engineer their availability.
Figure 2 — Smart gateway vs thin gateway
3Core Concepts
3.1 Bottleneck
Figure 3 — Gateway overhead (illustrative)
Bottleneck source
Mitigation
CPU-heavy filters (body rewrites, JSON parsing)
Avoid; stream bodies
Synchronous remote checks per request (introspection, remote rate limiter)
Cache JWKS, local token validation, Redis with pipelining
Connection pool limits to backends
Tune pools per route; HTTP/2 upstream
Thread-per-request with blocking I/O
Reactive (Netty) or virtual threads
Large payloads (uploads)
Direct-to-storage presigned URLs
Underprovisioning
Autoscaling on CPU and connections
Table 2 — Performance risks
3.2 Coupling
Figure 4 — Coupling: the gateway that knows too much
Coupling symptom
Cause
Remedy
Release queue at platform team
Central config ownership
Federated config (per-team route files, GitOps)
Gateway change needed for API field change
Payload transformation
Move mapping to service/BFF
Gateway contains pricing/validation
Business logic creep
Thin gateway principle
Every team needs gateway expertise
Complex custom plugins
Standard policies, templates
Table 3 — Organisational coupling
3.3 Centralized failure
Figure 5 — Centralised failure
Failure mode
Example
Bad configuration deploy
Route regex matches nothing → all 404
Certificate expiry
TLS handshake failures for all clients
Shared dependency outage
Redis down → every request blocked by rate limiter
Resource exhaustion
Connection leak → gateway unresponsive
Security incident
Compromised gateway = access to everything
Table 4 — Ways a gateway takes everything down
4How It Works Internally — Engineering Availability
A route change intended for /api/order-exports/** used a catch-all predicate with higher priority; for 18 minutes all order traffic hit the export service and returned 404. Route unit tests and canary config rollout (one gateway pod first, automated error check) now prevent this class of outage.
6.2 Redis took down the edge
The gateway's rate limiter failed closed when Redis failed over, rejecting all requests for 90 seconds. Switching to a local fallback limiter and alerting on degraded mode kept APIs available during subsequent Redis maintenance.
6.3 Worked example — capacity planning
Input
Value
Peak requests/s
40,000
Gateway instance capacity (measured, p99 < 10 ms overhead)
4,000 rps
Instances needed at peak
10
N+2 per AZ across 3 AZs
≥ 12 instances + autoscaling headroom
Table 9 — Size for peak, failure and headroom
6.4 Worked example — config change pipeline
Stage
Check
PR
Schema validation, route tests (WebTestClient), security lint (no public admin routes)
Staging
Synthetic traffic replay
Production canary
1 pod receives new config; compare 5xx/404 rates for 10 minutes
Rollout
Progressive; auto-rollback on anomaly
Table 10 — Treat configuration like code
6.5 Worked example — thin gateway checklist
Question
Target answer
Does any filter read or modify business payload fields?
No
Does the gateway call databases?
No
Can a service team change its routes without the platform team?
Yes (own route file, reviewed)
Is the gateway stateless except for rate-limit counters?
Yes
Table 11 — Reviewing a gateway for creep
6.6 Worked example — cell-based edge
Component
Per cell
Gateway
✔
Services + databases
✔
Cell router (thin, global)
Maps customer → cell
Failure impact
Only customers in failed cell
Table 12 — Cells bound the blast radius of everything, including the gateway
Rejecting low-priority traffic early keeps critical paths (checkout, payments) alive.
6.8 Worked example — certificate expiry defence
Control
Detail
Automated renewal
ACME / cloud certificate manager
Expiry alert
30, 14, 7 days
Synthetic TLS probe
External check of certificate validity
Runbook
Emergency manual renewal steps
Table 13 — A classic global-outage cause
6.9 Worked example — gateway SLOs
SLO
Target
Availability (non-5xx caused by gateway)
99.99%
Added latency p99
< 10 ms
Config change failure rate
< 1%
Time to rollback config
< 2 minutes
Table 14 — Measure the gateway itself
6.10 Worked example — security blast radius
Control
Purpose
Minimal privileges for gateway (no DB access)
Limit compromise impact
Separate admin plane, not internet-exposed
Protect configuration
Signed config artefacts
Integrity
Audit logs of config changes
Accountability
Table 15 — The gateway is a high-value target
6.11 Worked example — bypass and emergency paths
Path
Use
Internal ingress directly to critical service (restricted network)
Operations during gateway outage
Static maintenance response at CDN
Graceful degradation message
Runbook with DNS switch
Failover to secondary gateway fleet
Table 16 — Plan for the gateway failing
6.12 Worked example — measuring gateway overhead
Measurement
Method
Gateway span duration minus upstream span
Tracing
Load test with/without each filter
k6/Gatling
CPU per 1k rps
Capacity model
Table 17 — Evidence before optimisation
7Common Problems & Mistakes
Business logic and heavy transformations in the gateway.
Single-AZ or under-replicated deployments.
Unvalidated config changes pushed globally.
Fail-closed dependencies without deliberate choice.
Central team bottleneck for all route changes.
No monitoring of the gateway's own SLOs.
8Performance & Production Considerations
Aspect
Guideline
Capacity
Load-tested, autoscaled, N+2 per AZ
Latency
Measured overhead budget
Config
GitOps, tests, canary, fast rollback
Dependencies
Explicit fail-open/closed/fallback
Blast radius
Domains, cells, regions
Table 18 — Operational guidelines
9Architecture & Design Considerations
Adopt a thin gateway principle in architecture guidelines.
Federate ownership of routes while centralising the platform.
Design for gateway failure: redundancy, cells, bypass runbooks.
Include the gateway in chaos and load testing.
10Interview Questions & Answers
Q1BasicConcept
Why is an API gateway a potential single point of failure?
Every external request passes through the gateway, so if it is down or misconfigured, every API behind it becomes unreachable at once, even though the services themselves are healthy. Its failure modes are also global: a bad route change, an expired TLS certificate, a shared Redis rate limiter failing closed or a connection leak can each take down all traffic in seconds. A compromised gateway exposes everything too. That is why it is tier-0 infrastructure. Redundant instances across availability zones remove the single-machine failure, but not the single-component failure: one bad configuration rolled out to every instance still breaks everything, so change safety and blast-radius limits matter equally.
Q2BasicConcept
How can a gateway become a bottleneck?
A gateway becomes a bottleneck when work per request grows or capacity does not keep up with traffic. Common causes are CPU-heavy filters that parse or rewrite JSON bodies, synchronous remote calls per request such as token introspection or a remote rate-limiter check, too-small connection pools towards backends, blocking I/O on a thread-per-request model, and large uploads streamed through it. Each adds latency to every API at once. The fixes are local JWT validation with cached JWKS, streaming instead of buffering bodies, tuned upstream pools with HTTP/2, a reactive or virtual-thread runtime, presigned URLs for uploads, and autoscaling on CPU and connections, verified by load tests.
Q3IntermediateConcept
What is organisational coupling in the context of gateways?
Organisational coupling means service teams cannot change their own APIs without going through the gateway and the team that owns it. It grows when route configuration is centrally owned, when the gateway transforms payloads so a field change needs a gateway change, when business rules like pricing or validation creep into filters, and when custom plugins need specialist knowledge. The result is a release queue at the platform team, coordinated deployments and shared risk, the same failure pattern as the old ESB era. Remedies are a thin gateway, standard reusable policies, and federated configuration where each team owns its route file in Git, reviewed and deployed through GitOps.
Q4IntermediateDesign
How do you make a gateway highly available?
Run several stateless gateway instances spread across at least two, preferably three, availability zones using topology spread constraints, behind a multi-zone load balancer. Size for peak plus the loss of a zone and autoscale with an HPA on CPU and connections, pre-scaling before known events. A PodDisruptionBudget keeps enough instances during node maintenance, and graceful shutdown drains connections. Health checks must reflect real readiness. Availability also depends on change safety and dependencies: validated, tested and canaried configuration with instant rollback, automated certificate renewal with expiry alerts, explicit failure policies for Redis and the identity provider, and early load shedding. Measure the gateway with its own SLOs.
Q5Senior EngineerScenario
What should happen when the rate limiter's Redis is unavailable?
That must be an explicit, documented decision, because both naive options are bad. Failing closed rejects every request whenever Redis fails over, turning a cache problem into a full outage. Failing open removes all abuse protection exactly when an attacker might be causing the trouble. The usual recommendation is a local fallback: each gateway instance switches to an in-memory limiter with its share of the global limit, giving approximate protection while Redis is unavailable. Put a short timeout and a circuit breaker on the Redis call so slow responses do not add latency, alert on degraded mode, and test the behaviour with chaos experiments such as blocking Redis traffic.
Q6Senior EngineerDesign
How do you prevent configuration changes from causing outages?
Treat gateway configuration as production code, because a single bad route can break every API. Store it in Git and deploy it through GitOps with Argo CD or Flux. In the pull request, validate it against a schema, run route unit tests with WebTestClient that assert which service each path reaches, and lint for risks such as catch-all predicates or public admin routes. Replay synthetic traffic in staging. In production, roll it out as a canary to one instance first, compare 5xx and 404 rates for a few minutes, then progress gradually with automatic rollback on anomalies. Keep rollback under two minutes, and audit every change.
Q7Technical ArchitectConcept
What does "thin gateway" mean?
A thin gateway handles only generic, cross-cutting edge concerns: routing, TLS termination, authentication and coarse authorisation, rate limiting, request size limits, CORS, header normalisation and telemetry. It does not read or change business payload fields, call databases, hold business rules like pricing or validation, or shape responses for particular clients; that belongs in the services themselves or in backend-for-frontend services owned by the client teams. The benefit is that the gateway stays fast, stateless apart from rate-limit counters, and rarely needs to change, so it is not a bottleneck or a release queue. A useful review question is whether any filter would change if a business rule changed.
Q8Solution ArchitectDesign
How can the blast radius of gateway failures be limited?
Stop running one global gateway in front of everything. Split gateways by domain, such as orders, catalogue and payments, or by audience, such as partners versus consumer apps, so a failure affects one slice. For the strongest isolation, use cell-based architecture: each cell holds its own gateway, services and databases for a subset of customers, and a very thin global router maps customers to cells, so one bad change hits perhaps five percent of users. Add per-region gateways with DNS failover, roll configuration out cell by cell, and keep emergency paths ready: restricted internal ingress for critical operations, static maintenance pages at the CDN and documented failover runbooks.
Newsletter
Get new tutorials every week
New ArchitectMind tutorials and interview questions, once a week. No spam, unsubscribe anytime.
Your subscription could not be saved. Please try again.
Almost done! Check your inbox and click the confirmation link to complete your subscription.