Services

Resources

Company

API gateway

An API gateway is a server that sits between clients and a set of backend services and acts as their single entry point. It routes each request to the right service and handles shared concerns in one place: authentication, rate limiting, TLS termination, request logging and sometimes combining several backend calls into one response.

How it works

Clients call one host, such as api.example.com. The gateway matches the path and method to a route: /orders goes to the orders service, /users to the users service. Before forwarding, it checks the API key or token and applies a limit, for example 100 requests per second per key. Over the limit, it returns HTTP 429 without touching the backend. A mobile home screen that needs data from 3 services can make 1 call to the gateway, which fans out and merges the replies.

Why it matters in production

Each service no longer has to rebuild auth, limits and logging, and the gateway is a natural place for metrics on every call. It is also on every request path, so it needs high availability, capacity headroom and careful change control. Business logic should stay out of it.

See also

On the One2N blog

Further reading

Comic about an API gateway: an app calls orders, users, cart and search, and each service has its own login code; a gateway checks login once and routes /orders and /users to the right service; with a limit of 100 calls a second per user, call 101 gets a 429 and never reaches the backend; the gateway handles login, limits and logs with no business logic, and must stay up.