open atlas
↑ Back to track
System Design Foundations SD · 03 · 07

Traffic & edge: config and code reading

Read real load-balancer, gateway, and CDN config, then make the call: a health-check that lies, an algorithm mismatch, a single-instance gateway, and a cache header that leaks or goes stale.

SD Senior ◷ 14 min
Level
FoundationsJuniorMiddleSenior

Traffic bugs live in the config, not the prose: a health-check that only opens a socket, an algorithm that balances the wrong thing, a gateway with no replica, a cache header that caches the wrong response. Read each snippet, reason about what really happens under load, and pick the answer a senior engineer would commit to.

Practise the loop you run during a design or config review: locate the load-balancer, gateway, or CDN setting, reason about how it behaves under load and failure, and choose the change the behavior actually supports.

Snippet 1 — the health check

upstream api {
  server 10.0.1.10:8080;
  server 10.0.1.11:8080;
}
# health check
location /healthz { return 200 "ok"; }   # static 200, touches nothing
# node 10.0.1.11's DB pool is exhausted; every real request returns 500
Quiz

Node .11 passes /healthz and stays in rotation while returning 500s to users. Why, and what's the fix?

Snippet 2 — the algorithm choice

# cache tier: each node holds a hot subset of keys in memory
upstream cache_tier {
  least_conn;                 # balance by fewest active connections
  server cache-1; server cache-2; server cache-3; # ... 12 nodes
}
# observed: hit ratio is terrible (~10%); almost every request misses
Quiz

The cache tier uses least_conn and the hit ratio is ~10%. What's wrong, and what algorithm should it use?

Snippet 3 — the gateway deployment

# kubernetes deployment for the API gateway (fronts 15 services)
kind: Deployment
metadata: { name: api-gateway }
spec:
  replicas: 1                 # single instance
  strategy: { type: Recreate } # kill old pod, then start new
# all 15 services are reachable only through this gateway
Quiz

What's the risk in this gateway deployment, and what's the minimal fix?

Snippet 4 — the cache header

# response for GET /account/orders  (shows the logged-in user's orders)
HTTP/1.1 200 OK
Cache-Control: public, max-age=600
# served through a shared CDN; no Vary header
Quiz

This authenticated, per-user response carries Cache-Control: public on a shared CDN. What's the consequence and the fix?

Recall before you leave
  1. 01
    Why does a static-200 health check lie, and what makes a check meaningful?
  2. 02
    When does least-connections/round-robin give a terrible cache hit ratio, and what's the fix?
  3. 03
    Why is a per-user response with Cache-Control: public on a shared CDN dangerous, and how do you fix it?
Recap

Every traffic decision in this unit reduces to a setting you can read straight off the config. A health check that returns a static 200 (or just opens a socket) lies — it never touches the dependency chain, so a 500-returning node stays in rotation; make it probe the real DB/cache and add passive ejection. An algorithm must match the goal: least-connections/round-robin balance by count and destroy a cache tier’s hit ratio, where consistent hashing on the key preserves locality. A gateway at replicas: 1 is a textbook single point of failure with downtime on every deploy — run multiple replicas behind the balancer with a rolling update. And a per-user response with Cache-Control: public on a shared CDN is a data leak waiting to happen — use private/no-store and Vary. The senior habit is to find the setting, reason about how it behaves under load and failure, and choose the fix the behavior supports — not the one that papers over it.

Something unclear?

Ask a question about this lesson. Questions are anonymous and go straight to the author to make the lesson better.

shortcuts expand
search
K
prev piece
k
next piece
j
cycle tier
t
this menu
?
sources3
expand
  1. 01
  2. 02
  3. 03

Trademarks belong to their respective owners. Editorial reference only.