How it works · 12 of 49 Core
What are an API gateway and backend-for-frontend (BFF)?
One front door per client
API gateway & backend-for-frontend: An API gateway is one front door in front of many services: clients call it once, it checks who they are, routes the call, fetches from several services and returns one answer, so clients never learn how the services are split. A backend-for-frontend (BFF) is a gateway made for one kind of client (the phone app, the website, a partner), shaping each answer for it. The price: every request passes one desk, so it must stay thin and never become the bottleneck or the single point of failure.
Loading the animation…
Say it like this An API gateway is one front door that checks, routes and combines calls to many services; a backend-for-frontend is that door shaped for one kind of client, so the services behind can change without any app noticing.
Under the hood — for builders
- The source, in its words
- Microsoft's Azure Architecture Center: an API gateway "provides a centralized entry point for managing interactions between clients and application services. It acts as a reverse proxy." Without one, clients face complex code, tight coupling to how the services are split, "multiple network round trips", security repeated in every service, and a wider attack surface.
- Three jobs one gateway does
- Reverse proxy: a server that takes the client's call and makes it on the client's behalf. Microsoft names three patterns:
- Worked example: the phone's wait
- Assume a phone link of 100 ms per round trip and 20 ms for each service to answer inside the data centre. Five calls in turn cost five trips; five at once are fast but need five connections, five addresses and five auth checks; one gateway call costs one trip plus the slowest service:
- Backend for frontend (BFF)
- A gateway built for one kind of client. Sam Newman (2015): a BFF is "tightly focused on a single UI, and just that UI", ideally "owned by the team creating the user interface". The rule he quotes: "one experience, one BFF".
- In front of AI models
- An AI gateway is the same door before model providers: the app holds no keys; the door enforces limits, records spend and falls back. In our paper anthropics-commerce-agents, the assistants can run "through the company's own AI gateway".
- Measure it
- Gateway latency added per call (p50, p99) · calls per client screen · error rate per route · share of traffic per BFF · requests turned away by rate limits.
- Watch out
- Business rules creeping into the gateway make it a new monolith. Run several copies; one gateway is a bottleneck and a single point of failure. BFFs duplicate code; Newman accepts that until the third copy.
- Sources
- Microsoft, "API gateways", Azure Architecture Center, 2025 · Sam Newman, "Backends For Frontends", samnewman.io, 18 Nov 2015 · ShiniFrontiers paper anthropics-commerce-agents · all read in session.
What happens in the API gateway & backend-for-frontend animation, step by step?
- Without a front door, the phone app visits five counters itself: five slow round trips, and it must know where every counter is.
- An API gateway: one front door. It checks the key once, fetches from the counters in parallel and hands back one tray.
- Your turn: tap a guest. Each kind of client gets a tray shaped for it: a backend for frontend.
- Counters behind can split or move. Guests never notice, because only the front door knows the map.
- The price: every request passes one desk. Keep it thin and run more than one, or it becomes the bottleneck and the single point of failure.
- The same front door in front of AI model providers: keys, limits, spend and fallback in one place. Next: who waits for whom.
What everyday example explains API gateway & backend-for-frontend?
A hotel concierge. Guests ask one person; the concierge knows which counter holds what, checks the room key once, and hands each guest a tray made for them.
Why should a team care about API gateway & backend-for-frontend?
Once a product has several services and several kinds of client, letting each client call each service couples every app to your internal layout and repeats security everywhere. One door per kind of client keeps the inside free to change. The same door in front of model providers is where an AI product keeps its keys, limits and spend.