Apache + php-cgi = CPU 100%

Discussion in 'General' started by Snowman, Jan 1, 2012.

  1. Snowman

    Snowman Member

    Hi there,
    btw happy new year to all :). Since last upgrade of ispconfig, that failed (http://www.howtoforge.com/forums/showthread.php?t=55116), I have problem with CPU usage of apache and php-cgi. I don't know how to determine if there is so huge number of visitors of websites that i run or if there is some configuration problem related probably to PHP-CGI process.

    If I restart apache2 with init script, in 1-2 mins there are 100+ processes like:
    13552 ? R 0:00 /usr/bin/php-cgi -d open_basedir=/var/www/clients/client1/web6/web:/var/www/clients/client1/web6/tmp:/var/www/websitewhichihost.com/web:/srv/www/websitewhichihost.com/web:/usr/share/php5:/tmp:/usr/share/phpmyadmin:/etc/php...

    Sometimes there are more than 150 php-cgi processes.
    Then my CPU is like : http://www.upnito.sk/0/mvdexp6zk7sc7phba2dvrgjb5adm76wh.png

    Every advice from you will be pleasure for me.

    Thanks,
     
  2. till

    till Super Moderator Staff Member ISPConfig Developer

    Check the apache error.log of the website and the global apache error.log, espcially if there are any vlogger errors.
     
  3. Snowman

    Snowman Member

    These processes that spawn after starting apache are not by same website. There are couple of domains within : /usr/bin/php-cgi -d open_basedir=/var/www/clients/client1/web6/web:/var/www/clients/client1/web6/tmp:/var/www/websitewhichihost.com/web:/srv/www/domain.com/web:/usr/share/php5:/tmp:/usr/share/phpmyadmin:/etc/php... so probably it's not caused by 1 website.

    I will paste some logs :

    global /var/log/apache2/error.log
    Code:
    [Sun Jan 01 20:47:29 2012] [error] child process 23151 still did not exit, sending a SIGKILL
    [Sun Jan 01 20:47:29 2012] [error] child process 22584 still did not exit, sending a SIGKILL
    [Sun Jan 01 20:47:29 2012] [error] child process 22936 still did not exit, sending a SIGKILL
    [Sun Jan 01 20:47:29 2012] [error] child process 22470 still did not exit, sending a SIGKILL
    [Sun Jan 01 20:47:29 2012] [error] child process 22963 still did not exit, sending a SIGKILL
    [Sun Jan 01 20:47:29 2012] [error] child process 23000 still did not exit, sending a SIGKILL
    [Sun Jan 01 20:47:29 2012] [error] child process 22524 still did not exit, sending a SIGKILL
    
    Code:
    root@server:~# rgrep vlogger /var/log/ 
    /var/log/apache2/error.log.1:Argument "" isn't numeric in numeric gt (>) at /usr/local/ispconfig/server/scripts/vlogger line 463, <STDIN> line 323971.
    /var/log/apache2/error.log.1:DBI connect('database=dbispconfig;host=localhost:3306','ispconfig',...) failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) at /usr/local/ispconfig/server/scripts/vlogger line 514
    /var/log/apache2/error.log.1:DBI Error:  at /usr/local/ispconfig/server/scripts/vlogger line 514, <STDIN> line 344278.
    /var/log/apache2/error.log.1:DBI connect('database=dbispconfig;host=localhost:3306','ispconfig',...) failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) at /usr/local/ispconfig/server/scripts/vlogger line 514
    /var/log/apache2/error.log.1:DBI Error:  at /usr/local/ispconfig/server/scripts/vlogger line 514, <STDIN> line 344278.
    /var/log/apache2/error.log.1:Use of uninitialized value $DBI_DUMP in alarm at /usr/local/ispconfig/server/scripts/vlogger line 538.
    /var/log/apache2/error.log.1:DBI connect('database=dbispconfig;host=localhost:3306','ispconfig',...) failed: Lost connection to MySQL server at 'sending authentication information', system error: 32 at /usr/local/ispconfig/server/scripts/vlogger line 514
    /var/log/apache2/error.log.1:DBI Error:  at /usr/local/ispconfig/server/scripts/vlogger line 514, <STDIN> line 166512.
    /var/log/apache2/error.log.1:DBI connect('database=dbispconfig;host=localhost:3306','ispconfig',...) failed: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) at /usr/local/ispconfig/server/scripts/vlogger line 514
    /var/log/apache2/error.log.1:DBI Error:  at /usr/local/ispconfig/server/scripts/vlogger line 514, <STDIN> line 168148.
    /var/log/apache2/error.log.1:DBI connect('database=dbispconfig;host=localhost:3306','ispconfig',...) failed: Lost connection to MySQL server at 'sending authentication information', system error: 32 at /usr/local/ispconfig/server/scripts/vlogger line 514
    /var/log/apache2/error.log.1:DBI Error:  at /usr/local/ispconfig/server/scripts/vlogger line 514, <STDIN> line 647276.
    /var/log/apache2/error.log.1:DBI connect('database=dbispconfig;host=localhost:3306','ispconfig',...) failed: Lost connection to MySQL server at 'sending authentication information', system error: 32 at /usr/local/ispconfig/server/scripts/vlogger line 514
    /var/log/apache2/error.log.1:DBI Error:  at /usr/local/ispconfig/server/scripts/vlogger line 514, <STDIN> line 690622.
    /var/log/apache2/error.log.1:Argument "" isn't numeric in numeric gt (>) at /usr/local/ispconfig/server/scripts/vlogger line 463, <STDIN> line 273275.
    
    (this log is not from today but from yesterday)
    I didn't found nothing more suspicious in logs..
     
    Last edited: Jan 1, 2012
  4. till

    till Super Moderator Staff Member ISPConfig Developer

    Ok, thats what I guessed. Your problem is related to vlogger, please edit the file /etc/vlogger-dbi.conf and ensure that it contains the correct password for the mysql user that is used in that file. You can lookup the correct password in /usr/local/ispconfig/server/lib/config.inc.php. Then restart apache.
     
  5. Snowman

    Snowman Member

    I am able to login to mysql server at localhost with credentials from /etc/vlogger-dbi.conf, so it seems it's ok.. :(
     
  6. till

    till Super Moderator Staff Member ISPConfig Developer

    Ok.Then the errors might have been just temporary failures e.g. when mysql was restarted. Have you tried to switvh to fastcgi insteas of cgi and do you have a php binary cache like xcache or eacellerator installed?
     
  7. Snowman

    Snowman Member

    No I don't, it's let's say default multiserver setup. [only mysql service for websites is on other server]
     
  8. till

    till Super Moderator Staff Member ISPConfig Developer

    Then you should switch php to fastcgi in the website settings and install xcache with:

    apt-get install php5-xcache
    /etc/init.d/apache2 restart
     
  9. Snowman

    Snowman Member

    OK, you mean that when I login to Ispconfig, I select couple of websites from `top, where php-cgi process is and change the processing php to Fast-CGI? Because all my websites using "Fast-CGI" as php setting in ispconfig.

    I installed php5-xcache but, every time I restart apache, when apache is started all CPU's goes to 100% and it spawns these php-cgi processes that uses up to 10% of CPU, but there are lot of them.. and they are dedicated to four or more websites.
     
  10. voltagetag

    voltagetag New Member

    I have exactly same problem but couldnt find where it is

    My two VPS cpu and ram usage is raised over 100% php-cgi uses 100%, about a ten days i am trying to find solution.

    But this seems kind of linux virus
     
  11. voltagetag

    voltagetag New Member

    I fixed high resource usage problem by splitting large mysql table into 3. My mySQL table size was about 300MB and system resorces constantly 100% or above. After splitting by 3 its normal now.

    note: Now i am trying to find method to use other parts of table :)
     

Share This Page