API Gateways: What Belongs at the Edge—and What Should Stay in a Service
A sourced guide to gateway routing, authentication and rate limits, with practical boundaries for BFFs and backend business logic.
On this page

Imagine a mobile screen that needs an order, its delivery status and a payment summary. Without a gateway or a client-specific backend, the app may need to know several service endpoints and coordinate multiple requests. A gateway can offer one entry point; aggregation is an optional pattern, and the service owners still have to decide where that composition belongs. [1]
The Sprawl Problem in Microservice Architectures
Without a gateway, a client may need to know several service endpoints. This is one illustrative topology, not a claim about a particular company or a required design:
[ Mobile Client ] [ Desktop Browser ] [ Third-Party Partner ]
\ | /
\ | /
v v v
+-----------------------------------------------------------+
| Backend Services (example) |
| - Identity service |
| - Cart service |
| - Order service |
| - Product service |
+-----------------------------------------------------------+
- Security Vulnerabilities: Clients become coupled to internal service boundaries and may need to handle multiple public endpoints and failure modes.
- Protocol Mismatch: A client protocol and a backend protocol may differ, but translation should be introduced only when it solves a real compatibility or governance need.
- Redundant Auth Code: Teams may duplicate shared edge concerns unless ownership and enforcement boundaries are designed explicitly.
The API Gateway Pattern: Unified Edge Governance
An API gateway can sit between clients and backend services. Its position and responsibilities depend on the deployment; this simplified picture shows one possible boundary:
[ Public Clients: Mobile, Web, Partner APIs ]
|
(Example public entry point)
|
v
+-----------------------------------------------------------+
| API Gateway / Reverse Proxy |
| 1. Route requests to an owned backend |
| 2. Apply chosen TLS and identity policies |
| 3. Enforce client or tenant traffic limits |
| 4. Emit consistent edge telemetry |
| 5. Optionally aggregate or transform requests |
+-----------------------------------------------------------+
|
+-------------+-------------+
| (private service network) |
v v
+------------------+ +------------------+
| User Service | | Orders Service |
| (gRPC / Private)| | (gRPC / Private)|
+------------------+ +------------------+
Gateway capabilities are options, not a checklist
1. Request Routing and Versioning
The gateway decouples public URL structures from internal deployment locations. A gateway can map a stable public path to a backend destination or version. Canary policy, health-aware routing and regional failover depend on the chosen gateway and deployment configuration; the pattern alone does not provide them. [1]
2. Edge Authentication and Token Exchange
A gateway can perform an authentication or authorization check before forwarding a request. Services still need an explicit trust boundary for identity claims: if the gateway forwards identity headers, the network path must prevent clients from spoofing them and downstream services should validate what they rely on. Authentication placement depends on the threat model and the gateway’s capabilities. [1]
3. Distributed Rate Limiting
A gateway may enforce per-client or per-tenant traffic limits. A distributed limiter needs shared state or a deliberately approximate policy across gateway instances; a local counter alone can allow the aggregate rate to exceed the intended quota. Envoy’s global rate-limit design separates the proxy filter from a rate-limit service, illustrating that this capability has its own dependency and failure mode. [3]
4. Protocol Translation and Request Aggregation
Some gateways can transform protocols or aggregate several backend calls. That can reduce client chattiness, but it also moves composition logic into an edge tier. Microsoft’s guidance presents routing, aggregation and offloading as separate patterns, so choose each deliberately rather than assuming every gateway should do all three. [1]
Gateway Topologies: Centralized vs Backend-for-Frontend (BFF)
Microsoft describes a BFF as a client-specific service that can tailor responses and route or aggregate work behind a shared gateway. The choice creates another service to own, so use it when client needs justify that boundary. [2]
| Architecture | Topology | Primary Strength | Weakness |
|---|---|---|---|
| Shared gateway | Shared entry point for several teams or clients | Common routes and edge policy | Can concentrate ownership and change coordination |
| BFF | Client-specific application service behind an edge | Tailored responses and composition | More services and contracts to maintain |
| Mesh ingress | Edge traffic enters a service mesh through an ingress gateway | Can apply mesh identity and policy where configured | Does not replace every API product or client-facing feature |
Do
- Assign an owner for gateway policies, routes and their rollout; test configuration changes before broad exposure.
- Keep authentication and authorization responsibilities explicit across the gateway and backend services.
- Consider a BFF when client experiences need materially different response shapes, and include its deployment and maintenance cost in the decision.
Don't
- Do not make the gateway the home for domain decisions that change with service business rules.
- Do not assume one gateway product supports every required authentication, rate-limit and transformation feature.
- Do not trust client-supplied identity headers unless a trusted boundary strips and replaces them.
A gateway is useful when a stable edge boundary reduces client coupling or gives operators a clear place to enforce shared policies. Keep it small enough to understand, and choose a BFF or service-owned endpoint when work belongs to one user experience or domain. For more on client-specific composition, see the BFF pattern and its tradeoffs and a concrete gateway streaming tradeoff.
Frequently asked questions
Why might a frontend use an API gateway instead of calling each backend directly?
A gateway can give clients a stable entry point and route requests to services, reducing the number of backend locations clients must know. It also introduces another operational boundary and does not eliminate service failures or network latency.
What is the difference between an API gateway and a backend for frontend?
A gateway commonly handles edge routing and shared concerns. A backend for frontend is an application layer tailored to one client experience; it can sit behind a gateway and may compose or reshape data for that client. Microsoft describes these as related but distinct roles.
Do API gateways automatically translate REST requests to gRPC?
No. Some products and configurations support protocol translation, but it is an optional capability with mapping and operational costs. Use it only when a documented client/backend compatibility need justifies the extra boundary.
Can a gateway prevent cascading failures?
A gateway can enforce supported limits or timeouts, but a gateway alone does not guarantee resilience. Circuit breaking, load shedding, fallbacks and retry policies depend on the product and design; careless retries can increase pressure on an unhealthy service.



/* Comments */
Comments are offline right now — we reconnect automatically, nothing is lost.