CMD Guide
HomeSystem DesignProxy Server

Uses of Proxies

Uses of Proxies

A proxy is an intermediary server that sits in the request path between a client and a destination server, forwarding traffic on someone's behalf. The word matters: a proxy acts for another party. That single idea splits into two families that interviewers expect you to keep straight. A forward proxy sits in front of clients and represents them to the outside world (think a corporate egress gateway, or your VPN). A reverse proxy sits in front of servers and represents them to incoming clients (think Nginx, HAProxy, Envoy, or a CDN edge). The reason the concept exists is indirection: once every request funnels through a controlled choke point, you can observe, cache, secure, rewrite, and reroute traffic without touching the clients or the origin servers themselves.

How it works, precisely

Mechanically, a proxy terminates one connection and originates another. When a client opens a TCP (and usually TLS) connection to a reverse proxy, the proxy completes the handshake itself, reads the HTTP request, and then makes a separate upstream connection to the chosen backend. This is why a proxy can do TLS termination (decrypt at the edge, keep private keys off the app servers), connection pooling (keep warm keep-alive connections to backends and multiplex many short-lived client connections onto them), and header rewriting (inject X-Forwarded-For, X-Request-ID, strip internal headers).

The core capabilities layered on top of that indirection are:

A worked scenario

Suppose a news site serves 50,000 QPS at peak. Traffic analysis shows 92% of requests are for cacheable content (article HTML, images, CSS/JS) and only 8% are personalized or write requests. You place a reverse-proxy cache (or a CDN edge, which is a geographically distributed reverse proxy) in front of the origin.

With a 92% cache hit ratio, origin traffic drops from 50,000 QPS to 50,000 x 0.08 = 4,000 QPS. If each origin box safely handles ~500 QPS, you go from needing ~100 servers to ~8 — a 12x fleet reduction. Latency improves too: a cache hit served from edge memory returns in ~5-20 ms, versus ~150-300 ms for a full origin round-trip that touches the database. TLS termination at the proxy also saves each backend the ~1-2 ms CPU cost of handshakes and lets you pool, say, 200 warm upstream connections instead of opening a fresh one per client.

Trade-offs — when to use, when not

Reverse proxy vs. a plain L4 load balancer. A reverse proxy operates at L7 (HTTP-aware): it can route by path/header, cache, terminate TLS, and apply WAF rules. An L4 load balancer just forwards packets by IP:port — far cheaper per connection and lower latency, but blind to content. Use L7 when you need routing intelligence or caching; use L4 when you need raw throughput for non-HTTP or already-encrypted passthrough traffic.

Reverse proxy vs. API gateway. An API gateway is a specialized reverse proxy with authn/authz, per-consumer rate limits, request transformation, and billing. Reach for a gateway at an API's public edge; a plain reverse proxy suffices for internal fan-out and static caching.

Proxy caching vs. a dedicated cache (Redis/Memcached). Proxy caching is transparent and keyed by URL — great for whole HTTP responses. An application cache stores arbitrary objects your code looks up explicitly, giving fine-grained control at the cost of app complexity. They compose: CDN for responses, Redis for hot data.

When NOT to add a proxy: if traffic is low, uncacheable, or latency-critical, an extra hop just adds ~1-5 ms and one more thing to operate. For a single backend with no TLS/caching/routing needs, a proxy is over-engineering. And a naively single reverse proxy is a single point of failure — you must run it redundantly, which raises operational cost.

Pitfalls an interviewer probes

Key takeaways

🤖 Don't fully get this? Learn it with Claude

Stuck on Uses of Proxies? Open Claude, copy a block below, and it'll teach you this exact concept — visually and interactively.

🎨 Explain it visually

Build the mental picture, not memorization.

I just read a lesson on **Uses of Proxies** (System Design) and want to truly understand it. Explain Uses of Proxies from first principles using ONE vivid real-world analogy and a visual mental model — draw it as ASCII art or a clear step-by-step diagram — with a concrete example using real numbers. Then ask me one question to check I got the mental picture, and wait for my reply. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🤔 Walk me through it (interactive)

Socratic — adapts to where you're stuck.

Teach me **Uses of Proxies** interactively. Ask me ONE guiding question at a time, wait for my answer, and adapt to my confusion — build the idea with me step by step instead of explaining it all at once. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧪 Quiz me & fix my gaps

Active recall exposes what you missed.

Quiz me on **Uses of Proxies** with 5 questions, easy to tricky, ONE at a time. Tell me if each answer is right; at the end, explain clearly what I got wrong and why. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧠 Make it stick

Intuition + hook + flashcards for long-term memory.

Help me remember **Uses of Proxies** for the long term: give the one-sentence intuition, a memorable hook/mnemonic, a tiny worked example, and 3 active-recall flashcards (Q -> A). If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.

📝 My notes