At the start, your backend is one app.One codebase,one deployment,one address.The frontend knows exactly where to send every request,because there's only one place it can send them.
Then the project grows.Someone splits out the payments logic into its own service.Then notifications,.Then user profiles,then search,then the thing that resizes images.A year later you have a dozen small services,each doing one job,each living at its own address.
And now your mobile app has a problem it never used to have:
To load the homescreen,which of these twelve things do i need to talk to?And where do they all live?
Without something in the middle,the honest answer is:Frontend has to know all of it.Every address,every auth rule,every quirk.And every time you move or rename a service ,every client breaks.
That something in the middle is called an API gateway.Think of it as the front door of your whole backend.
In Part 3 we looked at reverse proxies,the receptionist standing in front of your server.An Api gateway is that receptionist after a promotion:same basic job,but much smarter about what's going on behind the desk.
The Hotel Analogy
Picture a big hotel.
Guests don't wander the building looking for the kitchen, the laundry, the spa, and the maintenance team. They go to one front desk. They say what they need, and the front desk:
- Checks who they are (are you a guest?)
- Figures out which department handles the request
- Passes it along
- Brings the answer back
- Politely says "no" to anyone trying to wander into the staff-only areas The departments behind the desk can be reorganized, moved to different floors, or even replaced entirely. Guests never notice, because they only ever deal with the front desk.
That's an API gateway. One entry point for every client, and a lot of quiet responsibility behind it.
So What Does a Gateway Actually Do?
Let's go through the job list in plain language.
1. Routing. The most basic job. A request for /payments goes to the payments service. /search goes to the search service. The client only knows one address, and the gateway handles the map.
2. Authentication. Instead of every one of your twelve services separately checking "is this person logged in and allowed to do this?", the gateway checks once, at the door. Requests that fail never get inside. Requests that pass get stamped with who the user is, so internal services can trust it.
3. Rate limiting. One misbehaving client (or one attacker) hammering your API can bring down services that were never built to defend themselves. The gateway can say "100 requests a minute per user, then slow down" before any of that traffic reaches your actual code.
4. Combining responses. Remember that home screen needing data from five services? Without a gateway, the phone makes five separate network calls over a mobile connection. With one, the phone makes one call, and the gateway talks to the five services behind the scenes (over a fast internal network) and stitches the answer together. Fewer round trips on a slow connection is a huge win.
5. Translating between worlds. Maybe your frontend speaks REST and one old internal service speaks something else entirely. The gateway can translate, so clients never have to care.
6. Logging and monitoring. Because every request passes through one place, it's the perfect spot to record who called what, how long it took, and what failed. You get a bird's-eye view for free.
7. Caching. Same idea as everything earlier in this series: if ten thousand people ask for the same thing, answer from memory instead of bothering the services ten thousand times.
8. Versioning. Want to roll out /v2/ of your API without breaking old mobile apps still calling /v1/? The gateway can route each to the right place.
Notice something? Many of these sound familiar. That's because a gateway is built on the same ideas as the reverse proxy and load balancer from the earlier parts. The difference is awareness of your API. A reverse proxy mostly shuffles bytes. A gateway understands that this is a request for the payments API from user #4821, and acts accordingly.
Gateway vs Reverse Proxy vs Load Balancer
This is where people get confused, so here's the cleanest way to think about it. They're layers of intelligence, not rivals:
| Mostly cares about | Example job | |
|---|---|---|
| Load balancer | Which copy of a server gets this request | "Server 2 is least busy, send it there" |
| Reverse proxy | Hiding and protecting the servers behind it | "Handle HTTPS, serve static files, forward the rest" |
| API gateway | What this API request means | "Is this user allowed to call /payments, and have they hit their limit?" |
In real systems, you'll often see all three stacked: a load balancer in front, spreading traffic across several gateway instances, each of which routes to services that are themselves load balanced. Each layer does the one job it's best at.
(And to make it more confusing: many tools do more than one job. nginx can act as all three if configured to. The roles are separate even when the software isn't.)
A Day in the Life of One Request
Let's follow a single request so this feels real. A user opens the app and taps "My Orders."
- The app sends one request to
api.yourapp.com/orders - A load balancer hands it to one of several gateway instances
- The gateway checks the token: valid, and it belongs to user 4821
- The gateway checks the rate limit: well under, fine
- It routes the request to the orders service, adding "this is user 4821" so the service doesn't have to re-verify anything
- The orders service responds. Maybe the gateway also quietly asks the products service for item names and merges them in
- The gateway logs the request and sends one tidy response back The user saw a screen load. The app made one call. Behind the curtain, five or six things collaborated. That's the whole magic trick.
The Honest Downsides
I'd be doing you a disservice if I made gateways sound like pure upside. They come with real trade-offs.
It's a single point of failure. If every request goes through the gateway and the gateway dies, everything dies. The fix is running multiple gateway instances behind a load balancer (see Part 2), but it's something you have to deliberately plan for.
It can become a bottleneck. All your traffic funnels through one layer. If it's slow, everything is slow.
It can become a dumping ground. This one bites teams the most. Gateways are so convenient that people keep stuffing business logic into them: "just one more transformation," "just one more special case." Over time, your gateway turns into a tangled monolith that everyone's afraid to touch, which is exactly what you were trying to escape by splitting into services. The rule of thumb: keep it about traffic, not business decisions.
It's one more thing to run. More components means more to deploy, monitor, and debug. For a small project, that cost can outweigh the benefit.
Do You Actually Need One?
Honest answer: probably not yet.
If you have one backend, or two or three services, a plain reverse proxy like nginx is usually plenty. A gateway earns its place when:
- You have many services and clients shouldn't need to know about each one
- You want consistent auth and rate limiting in one place instead of copy-pasted twelve times
- You serve mobile or slow-network clients that benefit from fewer round trips
- You have multiple teams who need a stable, shared front door while they change things behind it Starting with a gateway on day one of a tiny project is like hiring a hotel front desk team for a two-room guesthouse. Add it when the building grows.
Tools You'll Run Into
You don't have to build one from scratch. Popular options include:
- Managed cloud gateways: AWS API Gateway, Google Cloud API Gateway, Azure API Management. You configure them, the provider runs them
- Open source you run yourself: Kong, Traefik, KrakenD, Envoy-based gateways
- Do-it-yourself: a small service in your language of choice (Go is great at this) that routes and authenticates. For small setups, this is often the simplest honest answer If you've used Cloudflare or a platform like Vercel with rewrites and middleware, you've already touched gateway-style ideas without necessarily calling them that.
Where This Fits in the Series
Zooming out across everything so far:
- CDN (Part 1): bring content physically closer to users
- Load balancer (Part 2): spread traffic across many servers so none drown
- Reverse proxy (Part 3): stand in front of servers, hiding and protecting them
- API gateway (this post): give a growing backend one smart, consistent front door Each one answers a question that only appears once the previous layer exists. That's how real architecture grows: not designed all at once, but earned one problem at a time.
What to Take Away
- A gateway is a front door. Clients talk to one address, and everything behind it can change freely.
- It handles the repetitive stuff (auth, rate limits, routing, logging) once, at the edge, instead of twelve times inside.
- It's an evolved reverse proxy: same family, but it understands your API, not just bytes.
- Don't let it become a junk drawer. Keep business logic in your services.
- Wait until you need one. Complexity you add too early is complexity you maintain forever. The next time an app loads a screen full of data from a dozen places in a single smooth tap, you'll know there's probably a front desk somewhere, calmly handling the whole hotel.
Next in this series: caching beyond the CDN. Redis, in-memory caching, and the hardest question in computing: "when is this stored answer no longer true?"
Are you running a gateway today, or still happily on plain nginx? Tell me in the comments; I'm curious where people draw that line.

