My website is very slow at some times of the day, and I'm on the quest of finding out why. I'm currently looking into Apache memory usage and I have 2 tools that are supposed to tell me how much RAM it is currently using:
Apache2Buddy:
curl -sL https://raw.githubusercontent.com/richardforth/apache2buddy/master/apache2buddy.pl | perl
Returns:
apache2 is currently using 8849.18 MB of memory.
Then I have this command which uses ps
:
ps -ylC apache2 --sort:rss | awk '{sum+=$8; ++n} END {print "Tot="sum"("n")";print "Avg="sum"/"n"="sum/n/1024"MB"}'
Returns:
Tot=9047860(258)
Avg=9047860/258=34.2473MB
So according to this one liner, Apache2 is using about 9GB of RAM which matches Apache2Buddy result.
However, when I run htop
this is what I get:
Total memory usage seems to be only 2.7GB. Why this huge gap in results?