Concepts/2. Compute & Scaling/API Gateway Pattern
🚪
2. Compute & ScalingIntermediate

API Gateway Pattern

← All 150+ Concepts

Single unified gateway entry point for microservices that handles JWT verification, rate limiting, protocol translation (REST to gRPC), and request routing.

STAFF ENGINEER TAKEAWAY: Prevents client devices from making 20 individual microservice requests across cellular connections.
🔄

API Gateway Routing & Auth Flow

1
Mobile Client
Sends JWT in Authorization header
✓
2
API Gateway
Validates JWT signature & Token Bucket
✓
3
Protocol Translation
Converts JSON REST -> Protobuf gRPC
✓
4
Microservices Mesh
Routes to User, Order, & Payment Svcs
✓
✓ ARCHITECTURAL ADVANTAGES

Centralized security, telemetry, and rate limiting enforcement.

✗ TRADE-OFFS & COMPLEXITIES

Can turn into a monolith bottleneck if domain business logic leaks inside.

🏢

Production Systems Leveraging This Pattern

⚡Kong⚡AWS API GatewayNetflix Architecture↗⚡Apache APISIX
Simulate in Visual Canvas→Read 30-Chapter Curriculum→

More Topics in 2. Compute & Scaling

📈Vertical vs Horizontal Scaling

Vertical scaling upgrades a single node (CPU/RAM). Horizontal scaling adds stateless worker nodes across an autoscaling pool behind a load balancer.

⚖️Load Balancing (Layer 4 vs Layer 7)

Distributes incoming client requests across a pool of backend servers using algorithms like Round Robin, Least Connections, and IP Hash.

🛡️Reverse Proxy (NGINX / Envoy)

An intermediary proxy server that sits in front of web servers to terminate TLS, compress payloads (Brotli/Gzip), cache responses, and hide internal network topologies.

🍩Consistent Hashing & Virtual Nodes

Maps keys and nodes onto a circular hash ring [0, 2^32 - 1]. Adding or removing a node only redistributes K/N keys rather than re-indexing the entire database cluster.