Interview Prep/Networking/Load balancers and reverse proxies

Large downloads through nginx are slow to start, and the error log warns `an upstream response is buffered to a temporary file`.

IntermediateTroubleshootingLoad balancers and reverse proxies
Answer

Likely causes → With proxy_buffering on (default), nginx reads the upstream response into memory buffers and then spills to disk (proxy_temp_path) when the response exceeds them. Large files cause disk I/O and can fill the disk; slow disks delay delivery.

Diagnose →

grep 'buffered to a temporary file' /var/log/nginx/error.log | wc -l
du -sh /var/lib/nginx/proxy 2>/dev/null || du -sh /var/cache/nginx/proxy_temp
df -h /var

Fix → For large downloads, stream instead of buffering to disk:

location /downloads/ {
    proxy_max_temp_file_size 0;   # never spill to disk
    proxy_pass http://files;
}

Better: serve big static objects from S3/CloudFront or let the app return X-Accel-Redirect so nginx serves the file directly.

Prevent → Monitor the temp path's disk usage and keep large-object delivery off the app path.

All Networking questions Roadmap: Networking for DevOps

More on Load balancers and reverse proxies