What does an API gateway do, and why put one in front of your services?
Reviewed by Gurusankar M.
Short Answer
A gateway is a single entry point that handles cross-cutting concerns — authentication, rate limiting, routing/load balancing, TLS termination, request/response transformation, caching, and observability — so individual services don't each reimplement them. It also decouples clients from internal service topology.
On this page
Concept Made Simple
Coffee Chat Question
“What does an API gateway do, and why put one in front of your services?”
Remember It Faster
Mind Map Answer
- Cross-cutting
- auth, rate limit, TLS, logging
- Routing
- path → service, load balance
- Decouple
- clients don't know internal topology
- Risk
- can become a bottleneck / SPOF
Think Beyond the Expected
What If?
What's the downside of putting business logic in the gateway?
It becomes a fat, shared bottleneck and a single point of failure, couples teams to one deploy, and is hard to test. Keep the gateway to generic cross-cutting concerns; business logic belongs in the services (and run the gateway redundantly).
Real World
API gateways (Kong, AWS API Gateway, Spring Cloud Gateway) centralize auth/rate-limit/routing in microservices; the anti-pattern is an 'ESB-like' gateway stuffed with business logic.
Interviewer's Expectation
Keywords they're listening for:
- single entry point
- cross-cutting concerns
- routing/LB/TLS
- decouples clients
- avoid business logic / SPOF
Common Mistakes
- Business logic in the gateway
- Single non-redundant gateway (SPOF)
- Skipping per-service authZ (trusting the gateway alone)
Best Practices
- Gateway for generic cross-cutting only
- Run it redundantly; still authorize in services
- Consider BFF for client-specific needs
Follow-up Questions
- Gateway vs service mesh — how do they differ?
- How do you avoid the gateway being a SPOF?
- What is BFF (backend-for-frontend)?
Continue Learning with AI
Take this question deeper with your favourite AI assistant. Pick a depth, copy the prompt, or open it directly — AI is your learning companion, not a shortcut.
Plain-language foundations
I'm preparing for a software engineering interview and want to understand this from scratch, as a beginner. Topic: Auth (REST APIs) Interview question: "What does an API gateway do, and why put one in front of your services?" Please: 1. Explain the core idea in simple, plain language, using an everyday analogy. 2. Define any technical terms you use. 3. Walk through one small, concrete example. 4. Finish with a single sentence I can easily remember. Keep the tone friendly and assume I'm new to this topic.
Was this answer helpful?
Affiliate links
Tools for Your Developer Workspace
Equipment for a comfortable, productive setup.
As an Amazon Associate I earn from qualifying purchases.
- MonitorView on Amazon : BenQ EW2790U 27-inch Monitor (opens in a new tab)
BenQ EW2790U 27-inch Monitor
- LaptopView on Amazon : Acer Aspire One Laptop (opens in a new tab)
Acer Aspire One Laptop
- Office ChairView on Amazon : Wakefit Gravita Ergonomic Office Chair (opens in a new tab)
Wakefit Gravita Ergonomic Office Chair