ArchitectMind
  1. Home
  2. Tutorials
  3. Book 6 · Databases, APIs & Integration
  4. Volume VI
  5. Gateway Risks
Book 6 · Volume VI — API Management, GraphQL & Distributed API Design · Topic 1.3

Gateway Risks

Bottleneck, coupling and centralised failure

9 min readStage 3 · Systems8 interview questions
Chapter
Chapter 1 — API Gateway
Prerequisites
Topics 1.1, 1.2
You will be able to
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
Covers
Bottleneck; Coupling; Centralized failure
On this page
  1. 1. Concept / Definition
  2. 2. Why It Exists
  3. 3. Core Concepts
  4. 4. How It Works Internally — Engineering Availability
  5. 4A. Deep Dive — Limiting Blast Radius
  6. 5. APIs / Features / Syntax
  7. 6. Practical Examples
  8. 7. Common Problems & Mistakes
  9. 8. Performance & Production Considerations
  10. 9. Architecture & Design Considerations
  11. 10. Interview Questions & Answers

1Concept / Definition

Because all traffic flows through it, the gateway concentrates risk. The TOC names three:

Gateway risks and controls
Figure 1 — Gateway risks and controls
TOC riskDefinition
BottleneckThe gateway limits throughput or adds latency (CPU, connections, synchronous work, shared state)
CouplingTeams and services depend on the gateway for changes — logic and configuration centralised in one component owned by one team
Centralized failureA 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.

Smart gateway vs thin gateway
Figure 2 — Smart gateway vs thin gateway

3Core Concepts

3.1 Bottleneck

Gateway overhead (illustrative)
Figure 3 — Gateway overhead (illustrative)
Bottleneck sourceMitigation
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 backendsTune pools per route; HTTP/2 upstream
Thread-per-request with blocking I/OReactive (Netty) or virtual threads
Large payloads (uploads)Direct-to-storage presigned URLs
UnderprovisioningAutoscaling on CPU and connections
Table 2 — Performance risks

3.2 Coupling

Coupling: the gateway that knows too much
Figure 4 — Coupling: the gateway that knows too much
Coupling symptomCauseRemedy
Release queue at platform teamCentral config ownershipFederated config (per-team route files, GitOps)
Gateway change needed for API field changePayload transformationMove mapping to service/BFF
Gateway contains pricing/validationBusiness logic creepThin gateway principle
Every team needs gateway expertiseComplex custom pluginsStandard policies, templates
Table 3 — Organisational coupling

3.3 Centralized failure

Centralised failure
Figure 5 — Centralised failure
Failure modeExample
Bad configuration deployRoute regex matches nothing → all 404
Certificate expiryTLS handshake failures for all clients
Shared dependency outageRedis down → every request blocked by rate limiter
Resource exhaustionConnection leak → gateway unresponsive
Security incidentCompromised gateway = access to everything
Table 4 — Ways a gateway takes everything down

4How It Works Internally — Engineering Availability

Highly available gateway deployment
Figure 6 — Highly available gateway deployment
Availability controlImplementation
Redundancy≥ 3 instances per AZ, ≥ 2 AZs (or regions)
AutoscalingHPA on CPU/connections, pre-scaling for events
Graceful shutdownDrain connections (server.shutdown=graceful)
Config safetySchema validation, route tests, canary config rollout, instant rollback
Dependency isolationFail-open/closed policies for Redis, auth server
Certificate automationcert-manager/ACM with expiry alerts
Load sheddingReject early (429/503) under overload
Table 5 — Making the edge reliable

4ADeep Dive — Limiting Blast Radius

Mitigations
Figure 7 — Mitigations
TechniqueBlast radius
Single global gateway100% of APIs
Per-domain gateways (orders, catalog, payments)One domain
Cell-based architecture (gateway + services per cell of customers)One cell (e.g., 5% of customers)
Per-region gateways with DNS failoverOne region
Separate partner vs consumer gatewaysOne audience
Table 6 — Shrinking the impact of failures
Shared-dependency policyWhen Redis (rate limiter) is unavailable
Fail closedReject requests → outage (safe for abuse, bad for availability)
Fail openAllow requests without limits → availability over protection
Local fallback limiterPer-instance in-memory limits → approximate protection (recommended)
Table 7 — Decide explicitly

5APIs / Features / Syntax

ToolRisk addressed
Kubernetes HPA, PDB, topology spread constraintsAvailability, scaling
Argo CD/Flux + route unit testsConfig safety
Spring Cloud Gateway /actuator/gateway/refresh (controlled)Dynamic routes
Resilience4j circuit breakers per routeBackend failures isolated
Micrometer metrics, synthetic probesEarly detection
Chaos experiments (kill pods, block Redis)Verify behaviour
Table 8 — Gateway reliability toolkit
YAML
# Kubernetes excerpt for gateway pods
spec:
  replicas: 6
  template:
    spec:
      topologySpreadConstraints:
        - maxSkew: 1
          topologyKey: topology.kubernetes.io/zone
          whenUnsatisfiable: DoNotSchedule
          labelSelector: { matchLabels: { app: api-gateway } }
---
apiVersion: policy/v1
kind: PodDisruptionBudget
spec:
  minAvailable: 4
  selector: { matchLabels: { app: api-gateway } }

6Practical Examples

6.1 Regex outage

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

InputValue
Peak requests/s40,000
Gateway instance capacity (measured, p99 < 10 ms overhead)4,000 rps
Instances needed at peak10
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

StageCheck
PRSchema validation, route tests (WebTestClient), security lint (no public admin routes)
StagingSynthetic traffic replay
Production canary1 pod receives new config; compare 5xx/404 rates for 10 minutes
RolloutProgressive; auto-rollback on anomaly
Table 10 — Treat configuration like code

6.5 Worked example — thin gateway checklist

QuestionTarget 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

ComponentPer cell
Gateway✔
Services + databases✔
Cell router (thin, global)Maps customer → cell
Failure impactOnly customers in failed cell
Table 12 — Cells bound the blast radius of everything, including the gateway

6.7 Worked example — load shedding at the edge

JAVA
@Bean
GlobalFilter shedLoad(LoadMonitor monitor) {
    return (exchange, chain) -> {
        if (monitor.cpu() > 0.90 && !isCritical(exchange.getRequest())) {
            exchange.getResponse().setStatusCode(HttpStatus.SERVICE_UNAVAILABLE);
            exchange.getResponse().getHeaders().set(HttpHeaders.RETRY_AFTER, "5");
            return exchange.getResponse().setComplete();
        }
        return chain.filter(exchange);
    };
}

Rejecting low-priority traffic early keeps critical paths (checkout, payments) alive.

6.8 Worked example — certificate expiry defence

ControlDetail
Automated renewalACME / cloud certificate manager
Expiry alert30, 14, 7 days
Synthetic TLS probeExternal check of certificate validity
RunbookEmergency manual renewal steps
Table 13 — A classic global-outage cause

6.9 Worked example — gateway SLOs

SLOTarget
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

ControlPurpose
Minimal privileges for gateway (no DB access)Limit compromise impact
Separate admin plane, not internet-exposedProtect configuration
Signed config artefactsIntegrity
Audit logs of config changesAccountability
Table 15 — The gateway is a high-value target

6.11 Worked example — bypass and emergency paths

PathUse
Internal ingress directly to critical service (restricted network)Operations during gateway outage
Static maintenance response at CDNGraceful degradation message
Runbook with DNS switchFailover to secondary gateway fleet
Table 16 — Plan for the gateway failing

6.12 Worked example — measuring gateway overhead

MeasurementMethod
Gateway span duration minus upstream spanTracing
Load test with/without each filterk6/Gatling
CPU per 1k rpsCapacity 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

AspectGuideline
CapacityLoad-tested, autoscaled, N+2 per AZ
LatencyMeasured overhead budget
ConfigGitOps, tests, canary, fast rollback
DependenciesExplicit fail-open/closed/fallback
Blast radiusDomains, 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.

Almost done! Check your inbox and click the confirmation link to complete your subscription.
Keep going in Book 6

Databases, APIs & Integration

Volume I · Topic 1.1

Why Databases Exist

Database Fundamentals & Relational Data Modeling

Volume I · Topic 1.2

Database Management Systems

Database Fundamentals & Relational Data Modeling

Volume I · Topic 1.3

Database Architecture

Database Fundamentals & Relational Data Modeling

Volume II · Topic 1.1

Data Retrieval

SQL, Transactions, Concurrency & Database Performance

Volume II · Topic 1.2

Data Modification

SQL, Transactions, Concurrency & Database Performance

Volume II · Topic 1.3

Aggregation

SQL, Transactions, Concurrency & Database Performance

Volume III · Topic 1.1

JDBC Architecture

Java Persistence & Data Access Architecture

Volume III · Topic 1.2

PreparedStatement

Java Persistence & Data Access Architecture

Volume III · Topic 1.3

JDBC Transactions

Java Persistence & Data Access Architecture

Volume IV · Topic 1.1

Why NoSQL Exists

NoSQL, Caching & Polyglot Persistence

Volume IV · Topic 1.2

Categories

NoSQL, Caching & Polyglot Persistence

Volume IV · Topic 1.3

Trade-offs

NoSQL, Caching & Polyglot Persistence

Volume V · Topic 1.1

HTTP Architecture

API Design, HTTP & REST

Volume V · Topic 1.2

Methods

API Design, HTTP & REST

Volume V · Topic 1.3

Status Codes

API Design, HTTP & REST

Volume VI · Topic 1.1

Gateway Responsibilities

API Management, GraphQL & Distributed API Design

Volume VI · Topic 1.2

Gateway Patterns

API Management, GraphQL & Distributed API Design

Volume VII · Topic 1.1

Why Systems Integrate

Enterprise Integration & Messaging

Volume VII · Topic 1.2

Integration Styles

Enterprise Integration & Messaging

Volume VII · Topic 1.3

Point-to-Point Integration

Enterprise Integration & Messaging

Volume VIII · Topic 1.1

Integration Boundaries

Integration Architecture & Data Consistency

Volume VIII · Topic 1.2

Synchronous vs Asynchronous

Integration Architecture & Data Consistency

Volume VIII · Topic 1.3

Coupling

Integration Architecture & Data Consistency