Back to Notes

API Gateway

Problem

Design an API Gateway that acts as the single entry point for all client requests to a microservices backend.


Functional Requirements

  • Route requests to appropriate backend services
  • Authentication & Authorization
  • Rate limiting per client
  • Request/Response transformation
  • Load balancing

Non-Functional Requirements

  • Low latency (< 10ms overhead)
  • High availability (99.99%)
  • Horizontally scalable

High-Level Design

Client → DNS → Load Balancer → API Gateway Cluster → Microservices
                                      ↓
                                 Auth Service
                                 Rate Limiter
                                 Cache (Redis)

Key Responsibilities

ConcernImplementation
RoutingPath-based or header-based rules
AuthJWT validation, OAuth2, API keys
Rate LimitingToken bucket per client/endpoint
CachingRedis for GET responses
ObservabilityRequest logging, distributed tracing
Circuit BreakingFail fast when downstream is unhealthy

Relevance to Your Work

The Go API orchestration layer you're building IS an API Gateway wrapping Python/LangChain services. Same patterns apply.


Notes

<!-- Add as you study Gaurav Sen W4 -->