The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

100% CPU PHP Process

Discussion in 'Workarounds and Optimization' started by kokyew, Feb 11, 2010.

  1. kokyew

    kokyew Registered

    Joined:
    Sep 30, 2003
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    I have been facing this annoying problem and cannot find a solution. Some suggest that it is a hardware issue.

    This happens a few times in a day. We have suPHP installed and see some users in the server have a php process that is using 100% of CPU. The process is stuck and cannot be killed by "kill" or "kill -9". I can't check the process too because the "lsof -p PID" command freezes everytime I enter it. Then the server load keeps increasing and server crash in the end. The only way to stop this is making a force reboot.

    PHP 5.2.12
    cPanel 11.25.0-R43286
    MySQL 5.0.89

    We have exactly the same setup for other servers and do not have this problem.

    Can somebody suggest a way to fix it or at least try to locate the problem?

    Regards.
     
  2. cPanelDon

    cPanelDon cPanel Quality Assurance Analyst
    Staff Member

    Joined:
    Nov 5, 2008
    Messages:
    2,557
    Likes Received:
    7
    Trophy Points:
    38
    Location:
    Houston, Texas, U.S.A.
    cPanel Access Level:
    DataCenter Provider
    Twitter:
    What is the PHP handler set to? I would consider switching the PHP handler to SuPHP so that the problematic process, if recurring, could be easily tracked to the specific account that executed the script. When using SuPHP it would be possible to view the process and the user that executed the script using CLI tools such as "ps" and "top" via root SSH access.

    The following command will display the PHP handler and SuExec status for PHP:
    Code:
    # /usr/local/cpanel/bin/rebuild_phpconf --current
    Here is an example of the output as seen on a test system using SuPHP with both PHP 5 and PHP 4 with SuExec enabled; the displayed information may differ depending on the system-specific configuration and also depending on what options were used in the EasyApache build profile:
    Code:
    # /usr/local/cpanel/bin/rebuild_phpconf --current
    Available handlers: suphp dso fcgi cgi none
    DEFAULT PHP: 5
    PHP4 SAPI: suphp
    PHP5 SAPI: suphp
    SUEXEC: enabled
    The following WHM menu path and documentation will help in regard to switching the PHP handler:
    WHM: Main >> Service Configuration >> Apache Configuration >> PHP and SuExec Configuration
    Configuring PHP and suEXEC from the Command Line
    Apache PHP Request Handling
     
  3. kokyew

    kokyew Registered

    Joined:
    Sep 30, 2003
    Messages:
    4
    Likes Received:
    0
    Trophy Points:
    1
    suPHP is already enabled. Everytime there are different accounts having a high CPU usage php process. So I think it's not a particular account problem.

    There is nothing indicating the problem in the error log. We can't run "lsof", "strace" to check the process because the command will freeze everytime I run it.

    So weird....:(
     
  4. Spiral

    Spiral BANNED

    Joined:
    Jun 24, 2005
    Messages:
    2,023
    Likes Received:
    7
    Trophy Points:
    0
    There is literally hundreds of different possible causes for PHP scripts using high CPU usage numbers and loading the server under your configuration but if I were to take a blind stab at it based on experience with only the information you have provided, I would say that some of your accounts have files or folders configured with 777 permissions and that is likely causing scripts to get stuck as I have seen that problem on many servers and when the permissions are corrected, the load issues often go away.

    The following command might help you check for this issue:
    Code:
    #  find /home/*/public_html -perm 777
    
    The following is usually the best permissions for files on
    SuPHP based hosting accounts:

    755 All Folders (Including ones authors tell you to set 777)

    755 All CGI Scripts (.cgi, .pl, .pm, .py, .e)

    600 All PHP Scripts

    400 PHP Configuration Scripts (configure.php)
    *** Basically those you don't want WRITABLE ***

    644 Most everything else (Images, Plain HTML, Templates, Etc)

    Again you could have some other underlying issue but the above would definitely be the first thing that I would take a look at before looking
    next to anything else especially without any other information in hand.

    The next item I would look at is how many hosting accounts you have, what the traffic looks like for each of those account, and what are the hardware and resource specifications for your server?

    Hope that helps
     
Loading...

Share This Page