Score:0

Apache causing massive load spike after reboot

cn flag

My server is running Ubuntu 18.04.5 LTS, with LAMP stack (PHP 7.4), and apache version 2.4.29 using Prefork MPM. My server has 16 CPUs and 29GB of RAM. This server hosts 258 websites.

Whenever I reboot my server, I notice (using top command) that apache is creating a crazy amount of processes. This is completely overloading the server. This ONLY happens when I reboot the server, or I manually stop apache (service apache2 stop) and then start apache (service apache2 start).

Normally this is the output of top (during normal hours):

enter image description here

After rebooting or stopping and starting apache manually, the load average climbs to over 126.4! It slowly (over about 10-15 minutes) goes back to normal. For the first 5 minutes after rebooting or stopping and starting apache, the load just steadily climbs until it gets to about 126-130.

Here is my MPM configuration (/etc/apache2/mods-enabled/mpm_prefork.conf):

<IfModule mpm_prefork_module>
     StartServers           5
     MinSpareServers        5
     MaxSpareServers        10
     MaxRequestWorkers      150
     MaxConnectionsPerChild 0
 </IfModule>

Also KeepAlive is ON, MaxKeepAliveRequests is 100, and KeepAliveTimeout is 2.

What is very strange, is I made an exact copy of the server, and placed a handful of sites (6 websites) on the copy, and when I reboot, or start and stop apache on this copy server, this behavior does not happen. This is an EXACT copy of the server mentioned above, it is just only hosting 6 websites (WAY less traffic) instead of 258.

Could this problem be caused by too many client connections waiting on apache to respond during reboot, and when apache server finally comes back up it floods apache with connections?

Would increasing the values in my MPM configuration possibly help this? I've checked logs, and I never go over MaxRequestWorkers.

Michael Hampton avatar
cz flag
The first obvious thing to do is to get rid of the low performance mpm_prefork (and mod_php) and switch to php-fpm and mod_event (or better, nginx).
cn flag
This is a production server, could switching to mod_event cause issues? I just don't want to switch over and bring client sites down in the process.
Michael Hampton avatar
cz flag
Doing virtually anything can cause issues. But this is something you've apparently needed to do for a very long time, perhaps years, so you should start planning and testing to find out what those issues are likely to be.
ezra-s avatar
ru flag
I agree with Michael Hampton, except for the nginx part he takes every chance to promote. Apache is not causing that, php is. Problem is it is harder to see if you put it all together. If this is production, then I suggest you test a substitution with apache w/ mpm_event + php-fpm dealing with the PHP, not only you will have more control over your php configurations and even have several different ones if you please (fpm pools), but you will also have a very smaller footprint from apache, with a few processess but instead as many worker threads as needed.
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.