Help with a top log


#1

I’m having hard time understanding the ‘top’ of my VPS.

top - 10:19:18 up 17 min, 1 user, load average: 0.14, 0.23, 0.10
Mem: 2361344k total, 1258252k used, 1103092k free, 0k buffers
Swap: 921600k total, 0k used, 921600k free, 0k cached

PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
10913 root 20 0 139m 26m 20m S 0 1.2 0:00.52 apache2-ps19682
22743 karedas_ 20 0 87156 15m 8756 S 0 0.7 0:00.08 php5.cgi
22727 karedas_ 20 0 86980 15m 8788 S 0 0.7 0:00.13 php5.cgi
22736 karedas_ 20 0 86976 15m 8780 S 0 0.7 0:00.10 php5.cgi
22813 karedas_ 20 0 86980 15m 8752 S 0 0.7 0:00.10 php5.cgi
22746 karedas_ 20 0 86960 14m 8804 S 0 0.6 0:00.13 php5.cgi
22785 karedas_ 20 0 86632 14m 8820 S 0 0.6 0:00.12 php5.cgi
22707 karedas_ 20 0 86628 14m 8820 S 2 0.6 0:00.13 php5.cgi
22726 karedas_ 20 0 86632 14m 8812 S 0 0.6 0:00.14 php5.cgi
22687 karedas_ 20 0 86632 14m 8812 S 0 0.6 0:00.10 php5.cgi
22779 karedas_ 20 0 86628 14m 8820 S 0 0.6 0:00.14 php5.cgi
22761 karedas_ 20 0 86628 14m 8812 S 0 0.6 0:00.13 php5.cgi
22714 karedas_ 20 0 86632 14m 8796 S 0 0.6 0:00.12 php5.cgi
22797 karedas_ 20 0 86628 14m 8804 S 0 0.6 0:00.08 php5.cgi
22767 karedas_ 20 0 86632 14m 8796 S 0 0.6 0:00.11 php5.cgi
22766 karedas_ 20 0 86632 14m 8776 S 0 0.6 0:00.13 php5.cgi
22713 karedas_ 20 0 86632 14m 8764 S 0 0.6 0:00.10 php5.cgi
22735 karedas_ 20 0 86628 14m 8768 S 0 0.6 0:00.15 php5.cgi
22728 karedas_ 20 0 86628 14m 8768 S 2 0.6 0:00.11 php5.cgi
22784 karedas_ 20 0 86632 14m 8752 S 0 0.6 0:00.11 php5.cgi
22808 karedas_ 20 0 86632 14m 8752 S 0 0.6 0:00.11 php5.cgi
22847 dhapache 20 0 139m 8564 1704 S 0 0.4 0:00.01 apache2-ps19682
22709 dhapache 20 0 139m 8532 1716 S 0 0.4 0:00.01 apache2-ps19682
22695 dhapache 20 0 139m 8488 1732 S 0 0.4 0:00.01 apache2-ps19682
22760 dhapache 20 0 139m 8476 1744 S 2 0.4 0:00.01 apache2-ps19682
22741 dhapache 20 0 139m 8472 1716 S 0 0.4 0:00.02 apache2-ps19682
22792 dhapache 20 0 139m 8472 1740 S 0 0.4 0:00.00 apache2-ps19682
22848 dhapache 20 0 139m 8468 1728 S 0 0.4 0:00.00 apache2-ps19682
23153 dhapache 20 0 139m 8468 1740 S 0 0.4 0:00.00 apache2-ps19682
22781 dhapache 20 0 139m 8464 1740 S 0 0.4 0:00.00 apache2-ps19682
22816 dhapache 20 0 139m 8464 1740 S 0 0.4 0:00.00 apache2-ps19682
22845 dhapache 20 0 139m 8464 1720 S 0 0.4 0:00.01 apache2-ps19682
22729 dhapache 20 0 139m 8460 1740 S 0 0.4 0:00.00 apache2-ps19682
22731 dhapache 20 0 139m 8460 1716 S 0 0.4 0:00.02 apache2-ps19682
22782 dhapache 20 0 139m 8456 1716 S 0 0.4 0:00.01 apache2-ps19682
22843 dhapache 20 0 139m 8456 1728 S 0 0.4 0:00.01 apache2-ps19682
22711 dhapache 20 0 139m 8448 1716 S 0 0.4 0:00.00 apache2-ps19682
22780 dhapache 20 0 139m 8448 1716 S 0 0.4 0:00.00 apache2-ps19682
22694 dhapache 20 0 139m 8444 1716 S 0 0.4 0:00.00 apache2-ps19682
22744 dhapache 20 0 139m 8440 1712 S 0 0.4 0:00.01 apache2-ps19682
22814 dhapache 20 0 139m 8436 1716 S 0 0.4 0:00.00 apache2-ps19682
22834 dhapache 20 0 139m 8436 1740 S 0 0.4 0:00.00 apache2-ps19682
22836 dhapache 20 0 139m 8436 1712 S 0 0.4 0:00.00 apache2-ps19682
22748 dhapache 20 0 139m 8432 1728 S 0 0.4 0:00.00 apache2-ps19682
23145 dhapache 20 0 139m 8432 1720 S 0 0.4 0:00.00 apache2-ps19682
23154 dhapache 20 0 139m 8432 1716 S 0 0.4 0:00.01 apache2-ps19682
22762 dhapache 20 0 139m 8428 1712 S 0 0.4 0:00.00 apache2-ps19682
23291 dhapache 20 0 139m 8428 1704 S 0 0.4 0:00.00 apache2-ps19682
22825 dhapache 20 0 139m 8424 1716 S 0 0.4 0:00.01 apache2-ps19682
22826 dhapache 20 0 139m 8420 1712 S 0 0.4 0:00.00 apache2-ps19682
23147 dhapache 20 0 139m 8420 1708 S 0 0.4 0:00.00 apache2-ps19682
23159 dhapache 20 0 139m 8420 1716 S 0 0.4 0:00.00 apache2-ps19682
22739 dhapache 20 0 139m 8416 1712 S 0 0.4 0:00.00 apache2-ps19682
23091 dhapache 20 0 139m 8412 1716 S 0 0.4 0:00.00 apache2-ps19682
23134 dhapache 20 0 139m 8412 1712 S 0 0.4 0:00.00 apache2-ps19682

Are all these apache 2 normal ?
At the moment of this top, the site is unreachable.
The server is hosting a single domain that get an average 400k queries a day.
The scripts memory usage (with memory_get_peak_usage) never goes higher than 3Mb (85% queries are under 1Mb)
The server load often goes higher than 1Gb ram.
What am I doing wrong ?


#2

Well, each PHP process is using about 15 MB of memory, plus another 8 MB for the Apache process handling the request. With around 90 concurrent requests, I’m surprised you’re even fitting into 2.3 GB.

Your best bet is going to be to optimize your scripts to finish faster. (What’s killing you isn’t the memory usage per se, but how long they’re taking to finish.) Barring that, though, you may see some improvement by switching the domain from PHP-FastCGI to mod_php — you can do this from the Edit section of Manage Domains in the DreamHost Panel.


#3

Thanks a lot for your answer.
Script duration is the main problem of my site, it’s a facebook app with long facebook api queries. I try to setup some preload that could cut down process time, but I’ll sure won’t make miracles with facebook’s api.

I tried to switch to mod_php, I didn’t know it could improve performance.