One entry point for external clients: the API gateway, one backend per frontend, and GraphQL.
key idea / coordinatorservice / good pathin progress / watch outproblem / failureneutral
The problem: chatty clients
A screen often needs data from several services. Calling them all from a phone is slow and fragile.
The API gateway pattern
Put a single entry point in front of the services, like a facade.
Structure and ownership
Inside, an API layer per client sits on a common layer. Teams can own their own API.
BFFs in practice
Aggregation and filtering are the gateway's main value. Where it lives decides who can change it.
From Building Microservices: a BFF can also front third parties, such as royalty reporting or set-top boxes. A breaking change for one party then does not hit the others, and you avoid keeping old API versions alive for everyone.
Designing a gateway
It sits on every request, so it must be fast, concurrent and tolerant of failure.
Gateways, service meshes and the perimeter
Two proxy-based tools, two directions of traffic.
Many teams only need a simple reverse proxy for their own web and mobile clients.
API gateway
Service mesh
Traffic
North-south: from outside
East-west: between services
Shape
Reverse proxy at the perimeter
Proxy beside each service, plus control plane
Typical jobs
API keys, rate limits, routing
Discovery, timeouts, mutual TLS, logging
Rule
Keep behavior generic
Keep behavior generic
From Building Microservices: a mesh pays off with many services, several languages and Kubernetes. With five microservices it is hard to justify, and switching meshes later is painful. Treat it like choosing a broker or cloud: on the critical path.
Building one
Buy a product for routing, or write code when you need composition.
GraphQL gateways
Let the client describe exactly the data it wants.
GraphQL in depth
GraphQL was introduced as a gateway option. These are the trade-offs Newman stresses.
From Building Microservices: a GraphQL server can act as a BFF. Keep one per team boundary, because new types still need server changes. Use it at the edge, not for service-to-service calls.
Example: one public gateway
Bootstrapping Microservices shows the same idea on a small cluster: expose as little as possible.
Private video storage is reachable only through the app, never straight from the internet.
From Bootstrapping Microservices: in the kubectl listing only the gateway service has an external IP. Every other service is a ClusterIP service, visible inside the cluster only.
Recap
External clients should use an API gateway, not call services directly.
A gateway routes, composes, translates protocols and handles edge functions.
Backend for Frontend: one gateway per client type, owned by that client's team.
Use non-blocking I/O, reactive code and circuit breakers inside the gateway.
GraphQL lets each client ask for exactly the fields it needs.
A central aggregating gateway tends to become a bottleneck. Use one BFF per user experience, owned by the UI team.
API gateways handle north-south traffic and service meshes east-west. Keep both generic, with no business logic.
GraphQL suits the edge, but watch query cost, caching and writes.
Quick check
How does a GraphQL gateway avoid ten calls to Restaurant Service for ten orders?Show answer
It batches and caches loads with DataLoader, so the ten lookups become one batchFindRestaurants() call.
Why is it risky to do call aggregation inside a vendor API gateway product?Show answer
You end up baking business processes into a third-party tool you can only configure in its own language, which makes the logic hard to move later. Use GraphQL or a BFF for aggregation, or a saga if it is really a business process.