I have a server where nginx serves as a front load balancer and Apache with mod_php as application server on backend.
During peak hours if I restart apache as is immediately after restart it will die under current load because no caches primed yet.
I was thinking may be there is a way to do a slow start somehow? I.e. throttling number of connections depending on service uptime or something, like “allow no more than 10 connections than 1 second before” or something like this.
more low-level approach with iptables will work for me too, just do not know where to look for it.
Personally I wouldn’t rely on users warming the caches, I’d prefer to:
1/ Put Nginx into “Maintenance Mode” and have it temporarily proxy to a HTML file (fast)
2/ Warm the caches yourself using wget on the 8080 (or whatever) port (or preferably a cli PHP script if possible, but it isn’t always)
3/ Once warmed exit maintenance mode.
P.s when I refer to maintenance mode, I’m not aware of a switch that nginx has to enable this, but you could use bash scripts to alter the config to flick it on/off.