Current time: 11-25-2024, 09:55 AM Hello There, Guest! (LoginRegister)


Post Reply 
php5-cgi huge memory usage
Author Message
bleed Offline


Posts: 3
Joined: Aug 2010
Reputation: 0
Post: #1
php5-cgi huge memory usage
I'm using ispCP for 3 month now.
At first I didn't noticed, but now (for about month) php5-cgi processes ar using a lot of memory:

Code:
29329    vu2080    230356 kB    /usr/bin/php5-cgi
29195    vu2034    230284 kB    /usr/bin/php5-cgi
29340    vu2089    229840 kB    /usr/bin/php5-cgi
29330    vu2080    229632 kB    /usr/bin/php5-cgi
29320    vu2079    229336 kB    /usr/bin/php5-cgi
29321    vu2079    229120 kB    /usr/bin/php5-cgi
29191    vu2034    225880 kB    /usr/bin/php5-cgi
29338    vu2089    225880 kB    /usr/bin/php5-cgi
29341    vu2089    225880 kB    /usr/bin/php5-cgi
29324    vu2080    225436 kB    /usr/bin/php5-cgi
29336    vu2010    225396 kB    /usr/bin/php5-cgi
29337    vu2010    225352 kB    /usr/bin/php5-cgi
29314    vu2079    224912 kB    /usr/bin/php5-cgi
29334    vu2010    224912 kB    /usr/bin/php5-cgi
29316    vu2126    167644 kB    /usr/bin/php5-cgi
29308    vu2143    165820 kB    /usr/bin/php5-cgi
29309    vu2143    165568 kB    /usr/bin/php5-cgi
29357    vu2079    165424 kB    /usr/bin/php5-cgi
29315    vu2126    165148 kB    /usr/bin/php5-cgi
29389    vu2145    163764 kB    /usr/bin/php5-cgi
29388    vu2145    163644 kB    /usr/bin/php5-cgi
29318    vu2081    163472 kB    /usr/bin/php5-cgi
29319    vu2081    163472 kB    /usr/bin/php5-cgi
29356    vu2079    163160 kB    /usr/bin/php5-cgi
29347    vu2036    163112 kB    /usr/bin/php5-cgi
20179    vu2000    163108 kB    /usr/bin/php5-cgi
29346    vu2036    163104 kB    /usr/bin/php5-cgi
20191    vu2000    162580 kB    /usr/bin/php5-cgi
29353    vu2080    161968 kB    /usr/bin/php5-cgi
29327    vu2005    161072 kB    /usr/bin/php5-cgi
29328    vu2005    161072 kB    /usr/bin/php5-cgi
29352    vu2080    161020 kB    /usr/bin/php5-cgi
29306    vu2143    160344 kB    /usr/bin/php5-cgi
29310    vu2126    160344 kB    /usr/bin/php5-cgi
29312    vu2081    160344 kB    /usr/bin/php5-cgi
29323    vu2005    160344 kB    /usr/bin/php5-cgi
29342    vu2090    160344 kB    /usr/bin/php5-cgi
29343    vu2036    160344 kB    /usr/bin/php5-cgi
29350    vu2080    160344 kB    /usr/bin/php5-cgi
29354    vu2079    160344 kB    /usr/bin/php5-cgi
29378    vu2145    160344 kB    /usr/bin/php5-cgi
29387    vu2001    160344 kB    /usr/bin/php5-cgi
29404    vu2001    160344 kB    /usr/bin/php5-cgi
29406    vu2001    160344 kB    /usr/bin/php5-cgi
29538    vu2115    160344 kB    /usr/bin/php5-cgi
29540    vu2115    160344 kB    /usr/bin/php5-cgi
29541    vu2115    160344 kB    /usr/bin/php5-cgi
32277    vu2000    160344 kB    /usr/bin/php5-cgi

I think it's way too much.

I'm running on Ubuntu Linux 9.10
Linux 2.6.31-22-generic on x86_64
AMD Phenom™ II X6 1055T Processor, 6 cores, 4GB of RAM
using latest ispCP Omega 1.0.6

I tried to change some apache2 configuration, but finally came back to default.
If needed some specific configuration details - just ask!

What might it be? Some kind of bug or just because of my "knowledge" of linux and running servers?
(This post was last modified: 08-30-2010 06:53 AM by bleed.)
08-30-2010 06:26 AM
Find all posts by this user Quote this message in a reply
joximu Offline
helper
*****
Moderators

Posts: 7,024
Joined: Jan 2007
Reputation: 92
Post: #2
RE: php5-cgi huge memory usage
It's ok to use the memory which is available.

It's only a problem if the need of RAM is hight than the available....


But sometimes there are "lost" php-processes which consume cpu-load and memory. They can be killed. If you give the command how you go the list above - we can compare...

/J
08-30-2010 08:12 PM
Visit this user's website Find all posts by this user Quote this message in a reply
bleed Offline


Posts: 3
Joined: Aug 2010
Reputation: 0
Post: #3
RE: php5-cgi huge memory usage
I'm just beginner at linux. I used webmin to get that list.

Don't know if it's also normal, but RAM is full and also 2GB of swap is beeing used.
(This post was last modified: 08-30-2010 11:21 PM by bleed.)
08-30-2010 11:15 PM
Find all posts by this user Quote this message in a reply
vanshyr Offline
Junior Member
*

Posts: 33
Joined: Apr 2009
Reputation: 0
Post: #4
RE: php5-cgi huge memory usage
In shell prompt type the comand (as root): ps aux

It output a list of proceses used by all users, all programs and how much memory they are using.
maybe other process and not php/apache is using the big part of ram.

If i do it returns this:

Code:
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
clamav    3139  0.0  1.7 183848 143896 ?       Ssl  Jun29  32:49 /usr/sbin/clamd
root      8608  0.0  0.1  12912  8792 ?        S    Sep01   0:00 /usr/bin/perl /var/www/ispcp/engine/ispcp-apache-logger -e
root      8611  0.0  0.1  13184  9048 ?        S    Sep01   0:01 /usr/bin/perl /var/www/ispcp/engine/ispcp-apache-logger
www-data  8612  0.0  0.0  18404  5204 ?        S    Sep01   0:00 /usr/sbin/apache2 -k start
www-data  8613  0.0  0.0  18724  5328 ?        S    Sep01   0:00 /usr/sbin/apache2 -k start
www-data  8616  0.0  0.1 245092 12108 ?        Sl   Sep01   0:11 /usr/sbin/apache2 -k start
www-data  8644  0.0  0.1 244992 11968 ?        Sl   Sep01   0:10 /usr/sbin/apache2 -k start
vu2027    8698  0.0  0.0  20068  5664 ?        Ss   Sep01   0:00 /usr/bin/php5-cgi
vu2027    8699  0.0  0.0  20360  4752 ?        S    Sep01   0:01 /usr/bin/php5-cgi
vu2027    8700  0.0  0.0  20360  4756 ?        S    Sep01   0:01 /usr/bin/php5-cgi
vu2035    8758  0.0  0.0  20068  5660 ?        Ss   Sep01   0:00 /usr/bin/php5-cgi
vu2035    8759  0.0  0.1  27924 10620 ?        S    Sep01   0:27 /usr/bin/php5-cgi
vu2035    8760  0.0  0.1  28744 11208 ?        S    Sep01   0:28 /usr/bin/php5-cgi
vu2013    8765  0.0  0.0  20068  5664 ?        Ss   Sep01   0:00 /usr/bin/php5-cgi
vu2013    8766  0.0  0.0  21324  6316 ?        S    Sep01   0:06 /usr/bin/php5-cgi
vu2013    8767  0.0  0.0  21340  6408 ?        S    Sep01   0:05 /usr/bin/php5-cgi
vu2016    8801  0.0  0.0  20068  5664 ?        Ss   Sep01   0:00 /usr/bin/php5-cgi
vu2016    8802  0.0  0.0  20508  4604 ?        S    Sep01   0:00 /usr/bin/php5-cgi
vu2016    8803  0.0  0.0  20508  4604 ?        S    Sep01   0:00 /usr/bin/php5-cgi
vu2017    9134  0.0  0.0  20068  5664 ?        Ss   Sep01   0:00 /usr/bin/php5-cgi
vu2017    9135  0.0  0.0  24832  7476 ?        S    Sep01   0:03 /usr/bin/php5-cgi
vu2017    9136  0.0  0.1  27872 10500 ?        S    Sep01   0:04 /usr/bin/php5-cgi
backuppc  9149  0.0  0.0  13496  7864 ?        S    Aug11   0:14 /usr/bin/perl /usr/share/backuppc/bin/BackupPC -d
backuppc  9155  0.0  0.0   9692  4792 ?        S    Aug11   0:01 /usr/bin/perl /usr/share/backuppc/bin/BackupPC_trashClean
vu2015    9340  0.0  0.0  20068  5660 ?        Ss   Sep01   0:00 /usr/bin/php5-cgi
vu2015    9341  0.0  0.0  20068  3604 ?        S    Sep01   0:00 /usr/bin/php5-cgi
vu2015    9342  0.0  0.0  20068  3764 ?        S    Sep01   0:00 /usr/bin/php5-cgi
vu2033    9462  0.0  0.0  20068  5664 ?        Ss   Sep01   0:00 /usr/bin/php5-cgi
vu2033    9463  0.0  0.1  29404 12052 ?        S    Sep01   0:12 /usr/bin/php5-cgi
vu2033    9464  0.0  0.1  28388 11072 ?        S    Sep01   0:14 /usr/bin/php5-cgi
root     12563  0.0  0.0  12848  6164 ?        Ss   Aug31   0:00 /usr/bin/perl -T /usr/bin/iwatch -f /etc/iwatch/iwatch.xml -p /var/run/iwatch.pid -d
root     17577  0.0  0.0   4036  1204 ?        S    Aug21   0:00 /usr/bin/couriertls -server -tcpd /usr/lib/courier/courier/imaplogin /usr/bin/imapd Maildir

look i have many process too, but they consume 0.01 of Mem and 0 CPU, except the first one (1,7 Mem), an antivirus system, maybe in that moment it was analizing some file.

anf if i take a look at my memory usage right now:
Code:
free -m
             total       used       free     shared    buffers     cached
Mem:          8114       7858        255          0        202       6807
-/+ buffers/cache:        848       7266
Swap:         2859          0       2859

It seems that i have only 255 Mem free, but look at line 'buffers/cache' it have 7266Mb cached (can be replaced by differents process but is 'free' for be occuped by who needs).

Using swap memory 'nots good' it means that you lack Ram and need to 'virtualize' it in HDD.

So try the above command and try to find what process its really using the ram.
(You should to evaluate too, how many users you have?, maybe the RAM is well used but you need to put more ram on the server).

Smile
(08-30-2010 11:15 PM)bleed Wrote:  I'm just beginner at linux. I used webmin to get that list.

Don't know if it's also normal, but RAM is full and also 2GB of swap is beeing used.
09-03-2010 01:21 AM
Find all posts by this user Quote this message in a reply
Kwik Offline
Junior Member
*

Posts: 41
Joined: May 2007
Reputation: 0
Post: #5
RE: php5-cgi huge memory usage
I have the same problem for two days now.

Code:
vu2012    4374 77.8  0.1  81060  7940 ?        R    Oct26 626:20 /usr/bin/php5-cgi
vu2012   27454 52.2  0.1  81124  7992 ?        R    03:13 176:46 /usr/bin/php5-cgi
vu2012   27792 44.0  0.1  81088  7956 ?        R    03:53 131:19 /usr/bin/php5-cgi
vu2012   28747 33.5  0.1  81100  7992 ?        R    05:26  68:47 /usr/bin/php5-cgi
vu2012   29436 31.6  0.2  82100  9000 ?        R    06:23  47:01 /usr/bin/php5-cgi

The problem is that it uses a lot of cpu. I could kill them manually, but this wont stop it from happening again. Server has an uptime for 59 days and I didnt change anything but it started yesterday. I rebootet the server and I have the same problem today (yesterday there where a lot more processes, the server had a load average of 22 - 4gb ram amd 2 cpus debian etch, ispcp 1.0.6).

All the processes belong to the same virtual host.

Any ideas how to prevend this from happening?
10-27-2010 05:15 PM
Find all posts by this user Quote this message in a reply
pgentoo Offline
Member
*****
Dev Team

Posts: 326
Joined: Mar 2007
Reputation: 0
Post: #6
RE: php5-cgi huge memory usage
Is the website that is hosted on that account getting tons of traffic? That would be my first thing to check. Maybe the load isn't caused by "a problem", but more a result of increased traffic.
10-30-2010 06:56 AM
Find all posts by this user Quote this message in a reply
Kwik Offline
Junior Member
*

Posts: 41
Joined: May 2007
Reputation: 0
Post: #7
RE: php5-cgi huge memory usage
The traffic is pretty much the same. Seems to me that a few processes just dont stop running.
10-30-2010 08:09 AM
Find all posts by this user Quote this message in a reply
kilburn Offline
Development Team
*****
Dev Team

Posts: 2,182
Joined: Feb 2007
Reputation: 34
Post: #8
RE: php5-cgi huge memory usage
Use "strace" to see what are the processes doing.

Something similar happened to me once, and it was a silly programing mistake. Basically, the website had an "admin area" where the website owner could add/remove ad banners, and then two of them were shown randomly. At some point, the owner decided to remove all the banners but one, so the website ended up looping indefinitely trying to chose the second one.
10-30-2010 05:27 PM
Visit this user's website Find all posts by this user Quote this message in a reply
kassah Offline
Junior Member
*

Posts: 46
Joined: Oct 2010
Reputation: 1
Post: #9
RE: php5-cgi huge memory usage
Isn't that what php execution time limit is for? or did he disable that?
10-31-2010 01:28 AM
Find all posts by this user Quote this message in a reply
kilburn Offline
Development Team
*****
Dev Team

Posts: 2,182
Joined: Feb 2007
Reputation: 34
Post: #10
RE: php5-cgi huge memory usage
Yes and no. The default time limit is 30s, so if you have more than one request every 30s the process count will keep rising and rising until your server is starved.
11-02-2010 06:02 AM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 


Forum Jump:


User(s) browsing this thread: 1 Guest(s)