Architecture

API Gateway

Understanding API gateways in microservices architecture.

3 min readConcepts · System Design

What is an API Gateway?

An API Gateway is a single entry point for all client requests. It handles cross-cutting concerns like authentication, rate limiting, and request routing.


Without vs With API Gateway


Key Functions

FunctionDescription
RoutingRoute requests to appropriate services
AuthenticationVerify identity (JWT, OAuth)
AuthorizationCheck permissions
Rate LimitingPrevent abuse
Load BalancingDistribute traffic
CachingCache responses
Request TransformationModify requests/responses
SSL TerminationHandle HTTPS
MonitoringLog and trace requests

Request Flow


Patterns

Request Routing

Request Aggregation

Combine multiple service calls into one response:

Protocol Translation


GatewayTypeFeatures
KongOpen sourcePlugin ecosystem
AWS API GatewayManagedAWS integration
NGINXWeb serverHigh performance
EnvoyService meshAdvanced routing
TraefikContainer-nativeAuto-discovery

Rate Limiting Strategies

StrategyDescription
Token BucketTokens refill over time
Leaky BucketConstant rate output
Fixed WindowCount per time window
Sliding WindowRolling time window

Considerations

Pros

  • Single entry point
  • Centralized cross-cutting concerns
  • Protocol translation
  • Response aggregation

Cons

  • Single point of failure
  • Added latency
  • Additional complexity
  • Can become bottleneck

Interview Tips

  • Explain the main functions (routing, auth, rate limiting)
  • Discuss aggregation pattern for BFF (Backend for Frontend)
  • Know popular solutions: Kong, AWS API Gateway
  • Mention as potential bottleneck/SPOF
  • Compare with service mesh

Finished reading?

Mark it done to track your progress in Concepts.