Question #20 of 60•Security & Auth•Medium• ~3 min read

How do you design a secure API Gateway for routing, rate limiting, and SSL termination?

Executive Takeaway

Explore the edge proxy architecture, consolidating routing, authentication, SSL termination, and rate limits in a centralized entry point.

Architectural Breakdown & AnalysisFAANG Aligned

An API Gateway acts as the single secure entry point for all client requests into internal microservices.

Core Edge Responsibilities

  1. SSL/TLS Termination: Decrypts HTTPS at the gateway edge, passing unencrypted HTTP/TCP internally to reduce CPU load on microservices.
  2. Reverse Proxy & Routing: Maps external URI paths (/api/v1/orders) to internal service IPs using Service Discovery (Eureka/Consul).
  3. Cross-Cutting Concerns: Enforces central rate limiting, CORS headers, security payload sanitization, and request tracing headers (X-Request-ID).
NOTE — Recommended Tech Stack

Leverage battle-tested reverse proxies like Envoy, Kong (Lua/OpenResty), or Nginx for edge gateway deployments.

Key Architectural Comparison

Gateway FeatureL4 Proxy (HAProxy / NLB)L7 Gateway (Kong / Envoy / APISIX)In-App Middleware
Routing GranularityIP address & TCP/UDP port only.HTTP Path, Method, Headers, Cookies.Internal method calls.
SSL / TLS TerminationFast hardware pass-through.Full certificate termination & inspection.None.
Authentication & JWTNot supported.Centralized token validation & rate limiting.Duplicated across each service.
Latency OverheadSub-millisecond.2–5 milliseconds.Zero network overhead.
Previous QuestionHow do you scale search queries on a large product catalog (Elasticsearch)?Next Question What are the trade-offs of Cache Eviction Policies (LRU, LFU, ARC) in Redis & Memcached?

Continue Learning on Being SDE

Explore deep-dive system architecture modules, low-level object-oriented designs, and interview cheat sheets.