HardExperience level: 8-15 years1 min read

What does an API gateway do, and why put one in front of your services?

Reviewed by Gurusankar M.

Asked inAmazonMicrosoftGoogleDeloitte
#api gateway#cross-cutting#auth#rate limiting#routing
Report issue

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

  1. Gateway vs service mesh — how do they differ?
  2. How do you avoid the gateway being a SPOF?
  3. 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.
Open inChatGPTGeminiClaude

Was this answer helpful?

Affiliate links

Equipment for a comfortable, productive setup.

As an Amazon Associate I earn from qualifying purchases.