Question

Apache2 processes piling up to fill memory

Hello,

I’m using the 5$ droplet with phpMyAdmin 1-click installation and serving a REST API over apache2.

Couple hours after I restart my apache service, when I use the following command to view processes that use the most memory:

ps -eo pmem,pcpu,rss,vsize,args | sort -k 1 -r | less

I see a lot of the same processes that over time piling up and never being killed, hence filling up the memory to about 90% :


%MEM %CPU   RSS    VSZ COMMAND

 2.9  0.2 30016 500080 /usr/sbin/apache2 -k start
 2.8  0.1 28420 498072 /usr/sbin/apache2 -k start
 2.8  0.0 28464 500084 /usr/sbin/apache2 -k start
 2.7  0.1 27696 498056 /usr/sbin/apache2 -k start
 2.7  0.0 27796 498052 /usr/sbin/apache2 -k start
 2.7  0.0 27512 499672 /usr/sbin/apache2 -k start
 2.7  0.0 27496 498060 /usr/sbin/apache2 -k start
 2.7  0.0 27332 279668 /lib/systemd/systemd-journald
 2.6  0.2 26956 498068 /usr/sbin/apache2 -k start
 2.6  0.2 26460 498068 /usr/sbin/apache2 -k start
 2.6  0.1 26616 498068 /usr/sbin/apache2 -k start
 2.6  0.1 26392 498048 /usr/sbin/apache2 -k start
 2.6  0.1 26340 497964 /usr/sbin/apache2 -k start
 2.6  0.1 26280 498032 /usr/sbin/apache2 -k start
 2.6  0.0 27116 494872 /usr/sbin/apache2 -k start
 2.6  0.0 26964 498004 /usr/sbin/apache2 -k start
 2.6  0.0 26296 497972 /usr/sbin/apache2 -k start
 2.6  0.0 26288 498068 /usr/sbin/apache2 -k start
 2.5  0.3 26168 498028 /usr/sbin/apache2 -k start
 2.5  0.3 25952 497976 /usr/sbin/apache2 -k start

As soon as I run “systemctl restart apache2” all of these processes disappear and my used memory decreases by a lot.

And idea about what is wrong with my server?

Thanks in advance.


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Hi @hasancanboga,

Those are apache processes. Basically, people accessing your website/application. When you restart apache, you kill those processes since they are attached to the main Apache service. Basically you kill the sessions of your users. Having said that those can be malicious requests as well.

What you can try is to see the IP addresses which have accessed your application. You can view them and on which port they have connected, should be either port 80 or 443, with the following command :

netstat -punta

This command will show you the IP addresses accessing your server at the moment. If you see IP addresses from countries that generally shouldn’t be accessing your website/application, you can block them in IPtables.

Regards, KFSys