HomeBytesheetsRoadmapsUI TemplatesUI ToolsStack Discussion
3 Topics
Chapter•150 Minutes

API Gateways, Reverse Proxies and Load Balancers

Understand infrastructure commonly placed in front of production APIs.

Reverse Proxy

A reverse proxy accepts client requests and forwards them to backend services.

It can terminate TLS, route traffic, compress responses, add security headers, perform access logging, enforce limits, and hide internal network topology.

Clients communicate with the public endpoint while the proxy communicates with internal application instances.

Reverse Proxy Architecture

API Gateway

An API gateway is a specialized entry point that can provide routing, authentication integration, rate limiting, request transformation, observability, and aggregation across services.

In a microservice architecture, the gateway can present a unified external API while routing requests to multiple internal services.

However, putting too much business logic into the gateway creates a centralized bottleneck and makes the system harder to evolve.

Gateway Responsibilities
Routing: Map external paths to services
Authentication: Validate or delegate identity
Rate limiting: Protect public APIs
Observability: Collect edge metrics and traces

Load Balancing

Load balancers distribute requests across healthy instances.

Common strategies include round robin, weighted routing, least connections, and latency-aware routing.

Health checks can be shallow, such as checking whether a process responds, or deeper, such as checking critical dependencies. Deep health checks must be designed carefully because a dependency outage should not necessarily cause every instance to be removed from service.

Graceful shutdown is important: an instance should stop accepting new work while allowing active requests to finish.

Key Takeaways
  • Gateways and reverse proxies are infrastructure layers, not substitutes for API design.
  • Load balancers enable horizontal scaling.
  • Graceful shutdown is essential during deployments.