What does an API gateway do, and why put one in front of your services?
⚡ 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.
☕Coffee Chat Question
Concept Made Simple
“What does an API gateway do, and why put one in front of your services?”
🧠Mind Map Answer
Remember It Faster
🔥What If?
Think Beyond the Expected
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:
⚠️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
- 1Gateway vs service mesh — how do they differ?
- 2How do you avoid the gateway being a SPOF?
- 3What is BFF (backend-for-frontend)?
🧩Related Technologies
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?
⭐ Featured Products
Support our platform by exploring our recommended products.
As an Amazon affiliate, purchases through these links may earn us a small commission — at no extra cost to you. It helps keep Full Stack Interview Guru free.