Excessive Apache2 processes spawned on stock Ubuntu 20.04 Virtualmin install leading to memory depletion and eventual crashes

SYSTEM INFORMATION
OS type and version Ubuntu 20.04.4 LTS
Webmin version 1.994
Virtualmin version 1.840
Related packages Stock Install no customization at all

This is a follow up to my March 23 post about “Swap Memory leak on stock Ubuntu 20.04”…

I would add to that, but the forum closes after two months. @staff please reconsider two months is a bit short.

Thanks so much to @calport and @hescominsoon for having replied and trying to help me on that memory leak issue.

After much frustration and troubleshooting I have managed to isolate the problem, but not the root cause. To recap, I have over 10 servers installed exactly the same and just this one Ubuntu server is having the memory depletion problem.

What happens is every few hours the memory gets less and less and less, till eventually things start crashing. E.g. MySQL would OOM, or Webmin or whatever. It’s random but MySQL is often the straw that breaks the camel’s back.

Recap:

  • Server doesn’t have many sites, maybe 10. None are busy.
  • 5 GB RAM, 16 GB swap.
  • 48 hour graph showing depletion:

So it turns out a simple service apache2 reload fixes the problem.

Which meant I could do this:

Get SNMP warning about memory about to die…avoid panicking…

service apache2 reload

Graph recovers. I have all memory available again.

Straight away I do this to see open processes for a specific non-used site:

# ps -ef | grep henlie
root     1309437 1309255  0 20:37 pts/0    00:00:00 grep --color=auto henlie

That grep is for a single page WordPress site with the default theme of “Hello World”.

Since the site isn’t used, I open it in my browser, and then straight away do this:

# ps -ef | grep henlie
henliet+ 1309489 1309280  5 20:37 ?        00:00:00 /bin/php-cgi7.4
henliet+ 1309490 1309489 72 20:37 ?        00:00:00 /bin/php-cgi7.4
henliet+ 1309491 1309489  0 20:37 ?        00:00:00 /bin/php-cgi7.4
henliet+ 1309492 1309489  0 20:37 ?        00:00:00 /bin/php-cgi7.4
henliet+ 1309493 1309489  0 20:37 ?        00:00:00 /bin/php-cgi7.4
henliet+ 1309494 1309489  0 20:37 ?        00:00:00 /bin/php-cgi7.4
henliet+ 1309495 1309489  0 20:37 ?        00:00:00 /bin/php-cgi7.4
henliet+ 1309496 1309489  0 20:37 ?        00:00:00 /bin/php-cgi7.4
henliet+ 1309497 1309489  0 20:37 ?        00:00:00 /bin/php-cgi7.4
henliet+ 1309498 1309489  0 20:37 ?        00:00:00 /bin/php-cgi7.4
henliet+ 1309499 1309489  0 20:37 ?        00:00:00 /bin/php-cgi7.4
henliet+ 1309500 1309489  0 20:37 ?        00:00:00 /bin/php-cgi7.4
henliet+ 1309501 1309489  0 20:37 ?        00:00:00 /bin/php-cgi7.4
henliet+ 1309502 1309489  0 20:37 ?        00:00:00 /bin/php-cgi7.4
henliet+ 1309503 1309489  0 20:37 ?        00:00:00 /bin/php-cgi7.4
henliet+ 1309504 1309489  0 20:37 ?        00:00:00 /bin/php-cgi7.4
henliet+ 1309505 1309489  0 20:37 ?        00:00:00 /bin/php-cgi7.4
henliet+ 1309506 1309489  0 20:37 ?        00:00:00 /bin/php-cgi7.4
henliet+ 1309507 1309489  0 20:37 ?        00:00:00 /bin/php-cgi7.4
henliet+ 1309508 1309489  0 20:37 ?        00:00:00 /bin/php-cgi7.4
henliet+ 1309509 1309489  0 20:37 ?        00:00:00 /bin/php-cgi7.4

My single browser request has spawned at least 22 Apache processes!!

So multiple 22 with howmany ever other sites and there you have it. Endless Apache2 processes are spawned.

Please help me try to understand what could be the problem?

For now I’m scheduling a CRON job to “service restart apache2”…

Switch to php-fpm.

2 Likes

Thanks so much @Joe, the problem is resolved:

1 Like

This topic was automatically closed 8 days after the last reply. New replies are no longer allowed.