jakub holý

building the right thing, building it right, fast

Nginx: Protecting upstream from overload on cache miss

2015-10-01 05:09:35[Dev]Ops

These 2 magical lines will protect your upstream server from possible overload of many users try to access the same in cached or expired content: 

proxy_cache_use_stale updating timeout; # Serve the cached version even when outdated while refreshing it proxy_cache_lock on; # Only one req is allowed to load/refresh the item, others wait / get the stale one 


You can verify this using Shopify's Toxiproxy. 

<3 Nginx