← Back to microservices patterns map
🌐
Microservices Pattern

API Gateway Pattern

A single entry point routes, authenticates, rate-limits, and protects backend services.

gateway

Detailed Description

Gateways are edge infrastructure. They protect internal services from client-specific routing, authentication, throttling, and protocol concerns.

Keep business logic out of the gateway so it does not become a second monolith.

Visual Diagram

Request Flow through Gateway
  Client  →  [API Gateway]
               │ 1. Authenticate (JWT/OAuth)
               │ 2. Rate limit check
               │ 3. Route to service
               │ 4. Load balance
               ↓
  GET /users  → UserService
  POST /orders → OrderService
  GET /products → ProductService

Tradeoffs

Pros

Centralizes cross-cutting concerns, hides topology

Cons

Can become bottleneck or single point of failure

Examples: Kong, AWS API Gateway, Nginx, Traefik

API Gateway Pattern: Request Flow

Client

API Gateway

  1. 1. Authenticate (JWT/OAuth)
  2. 2. Rate limit check
  3. 3. Route to service
  4. 4. Load balance

Services

GET /users -> UserService
POST /orders -> OrderService
GET /products -> ProductService