Interview Prep/Networking/Load Balancing, Proxies & CDN

Design Nginx as a reverse proxy for two app servers with keepalive, timeouts and a health fallback.

IntermediateScenarioLoad Balancing, Proxies & CDN
Answer

Situation read → Typical hands-on config question.

What I'd do →

  1. Define the upstream: upstream app { server 10.0.1.10:8080 max_fails=3 fail_timeout=10s; server 10.0.1.11:8080; keepalive 32; }
  2. Proxy: location / { proxy_pass http://app; proxy_http_version 1.1; proxy_set_header Connection ""; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 3s; proxy_read_timeout 30s; }
  3. Validate with nginx -t and reload with nginx -s reload
  4. Test failover by stopping one backend and watching access.log

Why → Upstream keepalive avoids a new TCP handshake per request, and explicit timeouts prevent hung workers.

Interview tip → Say open source Nginx has only passive health checks.

All Networking questions Roadmap: Networking for DevOps

More on Load Balancing, Proxies & CDN