Index/API gateway

SponsorGitHub
Key technologyEdge tier3 min

API gateway

The front door: TLS, routing, auth, rate limits and timeouts, in one place instead of every service.

At a glance

What it is
An L7 reverse proxy every external request passes through
Owns
TLS, routing, token validation, quotas, timeouts, retries
Does not own
Your domain: fine-grained authorisation stays in the service
Shape
A stateless tier of many instances behind a load balancer
Direction
North-south. East-west traffic is a service mesh's job
Cost
One extra hop, a millisecond or two

Key concepts and capabilities

The short listwhat it gives you
Know the neighbours — a load balancer spreads connections, a gateway understands the API, a mesh handles east-west
Authenticate once — validate the token at the edge and forward a trusted identity header downstream
Authorise in the service — whether this user may edit that document is domain knowledge the gateway lacks
Rate limits live in Redis, not in each instance, or you let through N times your limit
Timeouts and budgets per route, retries with jitter on idempotent methods only, and a breaker on failing dependencies
Routing and rollout — path and header routing, versioning, canary by sending 1% of traffic
The BFF — a gateway per client shape, so mobile gets one aggregated payload instead of eight calls
Observability for free — one place sees every request, its latency, its error rate and its trace id
Keep logic out — a gateway that starts joining data has become a distributed monolith

Use cases

One front door for every request

Cross-cutting concerns live in one tier instead of being reimplemented in each service: terminate TLS, validate the token, apply the quota, set a deadline, route. In an interview this is one sentence and a box — it is table stakes, not a talking point.

FocusClick a node for details

A rate limit that counts every instance

Per-instance counters silently let through N times your limit, because each gateway only sees its own share of traffic. The bucket lives in Redis and the check-and-decrement is one Lua script, so the limit is global and atomic.

Queue / streamFocusClick a node for details

One call instead of eight, for mobile

A backend-for-frontend is a gateway specialised per client: it fans out in parallel, sets a deadline per call, and returns a compact payload shaped for one screen. The trap is latency — a BFF is as slow as its slowest dependency unless it degrades.

FocusClick a node for details

Shifting traffic to a new version

Header- and weight-based routing is how a migration happens without a flag day: 1% of traffic to the new implementation, watch its error rate and latency at the gateway (which already sees every request), then move the dial.

FocusClick a node for details