{}DSA Atlas

The Request Journey — Proxies, Load Balancers & CDNs

What happens when you type a URL, end to end — forward vs reverse proxies, API gateways, L4 vs L7 load balancing, balancing algorithms, health checks, sticky sessions, global load balancing, and how CDNs cache and accelerate content.

Intermediate → Advanced7 interview questions

What happens when you type a URL

BrowserHSTS · cache · SW 1. DNSname → anycast IP 2. TCP / QUIChandshake to the edge 3. TLS 1.3verify cert, derive keys 4. CDN edge (PoP)cache hit? WAF, DDoSstatic assets served here 5. Load balancerL4 → L7, TLS, routing 6. App serversstateless, autoscaled cacheRedis databaseprimary + replicas 7. Browser rendersHTML → DOM, CSS → CSSOMfetch subresources (CDN)run JS → layout → paintkeep connections alive Typical cold page load: DNS 20–100 ms · TCP+TLS 1–2 RTT · server 50–300 ms · rendering 100+ ms
The full path of a request. Each hop is a place to cache, secure, balance, or fail.

The interview-ready narrative

  1. URL parsing & HSTS → scheme forced to HTTPS; check the browser cache and service worker.
  2. DNS → recursive resolution; often lands on an anycast CDN IP.
  3. Connection → TCP three-way handshake (or QUIC), then TLS 1.3 (SNI, certificate validation, ECDHE key agreement).
  4. HTTP request → over HTTP/2 or HTTP/3, with cookies, compression preferences.
  5. Edge → CDN PoP serves cached content or forwards; WAF and DDoS filtering.
  6. Load balancer → L4 spreads connections; L7 routes /api vs /static, terminates TLS, retries.
  7. Application → stateless servers; read-through cache; database queries; maybe calls to other services or queues.
  8. Response → status, headers (Cache-Control, Set-Cookie, security headers), compressed body.
  9. Rendering → critical rendering path, subresource fetches (multiplexed), JavaScript execution, paint.

Proxies

Forward proxy (client side) client client proxy internet hides clients · egress policy · caching Reverse proxy (server side) internet proxy / LB app app hides servers · LB · TLS · caching · WAF
Same mechanism, opposite side of the conversation.

API gateway

A specialised reverse proxy for APIs: authentication (JWT/API keys/OAuth), rate limiting and quotas, request/response transformation, routing to microservices, aggregation (BFF), observability, API versioning, developer portal. Examples: Kong, Apigee, AWS API Gateway, Envoy-based gateways, Kubernetes Gateway API implementations.

Load balancing

Where load balancers sit

Text
Internet → (DNS / anycast) → L4 LB → L7 LBs / API gateway → service instances
                                                         → internal LBs / service mesh → other services

L4 vs L7

L4 (transport)L7 (application)
SeesIPs, ports, TCP/UDPURLs, headers, cookies, gRPC methods
Balancesconnectionsrequests
TLSpassthrough possibleterminates
Featuresraw speed, any protocolpath routing, retries, canaries, auth, caching
ExamplesAWS NLB, Maglev, LVS, HAProxy TCPAWS ALB, nginx, Envoy, HAProxy HTTP, Traefik

Algorithms

AlgorithmGood for
Round robin / weighted round robinuniform requests
Least connections / least outstanding requestsvariable request durations
Least latency (EWMA)heterogeneous backends
Power of two choiceslarge fleets, low coordination
IP hash / consistent hashing (ring hash, Maglev)affinity, cache locality
Randomsimple, surprisingly good at scale

Health checks and failure handling

  • Active checks (GET /healthz every few seconds) and passive checks (outlier detection on errors/latency).
  • Distinguish liveness (restart me) from readiness (don't send me traffic yet).
  • Connection draining on deploys and scale-in; slow start for new instances (warm caches/JIT).
  • Retries only for idempotent requests, with budgets to avoid retry storms.
  • Load balancers themselves are redundant (active-active pairs, managed services, anycast).

Global load balancing

Route users to the best region with GeoDNS/latency-based DNS or anycast global load balancers (Google Cloud LB, Cloudflare, AWS Global Accelerator); fail over between regions on health.

CDNs

user (Mumbai) user (Paris) user (NYC) edge PoP BOM edge PoP CDG edge PoP JFK regional shield(mid-tier cache) originS3 / app servers dashed = only on cache miss; the shield collapses many edge misses into one origin request
Tiered caching keeps origin traffic tiny even with hundreds of PoPs.
TopicNotes
Routing to PoPsanycast or GeoDNS
Cache keyURL + selected headers/cookies/query params — keep it small for high hit ratios
TTLsfrom Cache-Control/s-maxage, overridable by CDN rules
Invalidationpurge by URL, prefix or surrogate key/tag; prefer versioned URLs (app.3f9a.js)
Origin shielding / tiered cacheprotects the origin from miss storms
Request collapsingmany concurrent misses for one object → one origin fetch
Dynamic accelerationTLS near users, persistent tuned connections to origin, route optimisation
SecurityDDoS absorption, WAF, bot management, signed URLs/cookies for private content
Edge computeWorkers / Lambda@Edge / Fastly Compute for redirects, A/B, auth, personalisation
Metricscache hit ratio (aim > 90% for static), origin offload, edge latency

Interview questions

0 / 7 marked confident

Answer out loud first, then open the model answer. Mark a question confident only when you could explain it to an interviewer without notes.