We're running about a dozen WordPress sites on this server, and performance is really slow, with 'Service Unavailable' messages popping up from time to time. Restarting Apache and PHPFPM solves that for a short while, but it grinds down again sometime in a few days, sometimes in only a handful of hours.
We're also running Memcached - default config except 256M
I'm monitoring the www.pool log, and it keeps suggesting raising the start_servers, and min/max_spare server settings, however while that eliminates that warning, it doesn't solve the problem.
Currently those are set to start=70, min=50, max=90 and max_requests = 1000
This is a 6 core, 16GB Linode. Running HTOP shows all 6 cores mostly pinned at 100%
Memory usage is 11GB out of 16GB, with Swap 374M out of 512M
I had noticed when running journalctl -u php8.3-fpm some OOM entries, so have backed the start/min/max numbers down to their current levels (were 80/60/100).
I've been reading posts about configuration for days, and everything is pushing me to increasing the start/min/max settings, but that's not making the situation better, and may be making things worse, so I'm thinking I'm either looking in the wrong place, or adjusting in the wrong direction.
The primary goal is stability - this box has enough resources to be bulletproof. The secondary goal is performance - it should be extremely responsive, so I want to be sure I'm getting the most out of the available ram without compromising stability.
Any insight or suggestions would be greatly appreciated.
Update: The 'Tuning Apache' articles assume the use of mod_prefork, whereas PHPFPM uses mod_event. There's also the addition of memcached, making this a bit of a three-body problem. The article suggested is also 5 years old.
While I understand that configurations will depend on individual application loads, there also has to be a generally accepted, average configuration for a 16GB Ubuntu server running Apache2, PHPFPM, and Memcached. Hosting companies aren't tuning individual server instances for the specific customer sites that happen to get load balanced onto an instance, they must use a base, general purpose configuration and I can't find that documented anywhere. Maybe those configs are proprietary secret sauce, but a good starting point shouldn't be black magic.
mpm_event configuration in apache is currently:
StartServers 6
MinSpareThreads 25
MaxSpareThreads 75
ThreadLimit 64
ThreadsPerChild 25
MaxRequestWorkers 500
MaxConnectionsPerChild 0
My understanding is on a 6 core server, StartServers should be 6. Can anyone confirm that?