Please whitelist cPanel in your adblocker so that you’re able to see our version release promotions, thanks!

The Community Forums

Interact with an entire community of cPanel & WHM users!

Tracking down the cause of apache hanging processes

Discussion in 'EasyApache' started by Gareth-AWD, Jan 30, 2019.

  1. Gareth-AWD

    Gareth-AWD Well-Known Member

    Joined:
    Jul 3, 2008
    Messages:
    187
    Likes Received:
    6
    Trophy Points:
    68
    Location:
    London, UK
    cPanel Access Level:
    Root Administrator
    What's the best way of tracking down hanging processes. I have a bunch of new sites using our new CMS system that randomly hang. They use PHP 7.2 and do not seem to die after max execution time.

    At first I thought it was persistent PDO database connections in the script, but it still does it after disabling that.

    There's nothing in the PHP error log, but in my process list I see

    /usr/sbin/httpd -k start starting to use 90% CPU until I kill it. The process numbers aren't always in the apache status but if they are they are "W" statuses. From a user point of view the script does all its execution but it seems to just hang after the last command.

    My questions:

    1. Why aren't these processes killed off automatically (be it max_execution_time or something else)?
    2. What command can I use to find the last script file, PHP code, DB query, that was executed on that process that caused the hang.

    lsof | grep {process_number}

    will tell me which files were accessed last on the process, but need to narrow it down further.

    As far as I can tell the apache access_log doesn't list the process

    I'm also using suPHP instead of cgi
     
  2. cPanelLauren

    cPanelLauren Forums Analyst II Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    5,815
    Likes Received:
    443
    Trophy Points:
    233
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    They aren't being killed off automatically because they're sitting in W - this is a coding issue

    I don't think you'll be able to get that detailed with lsof -p but you might try strace to see the specific system calls.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  3. Gareth-AWD

    Gareth-AWD Well-Known Member

    Joined:
    Jul 3, 2008
    Messages:
    187
    Likes Received:
    6
    Trophy Points:
    68
    Location:
    London, UK
    cPanel Access Level:
    Root Administrator
    Thanks, but with regard to the first point about being a coding issue. We switched to from suphp to fcgi and the problem went away suddenly. Surely if it was a coding issue, this wouldn't be the case.
     
  4. cPanelLauren

    cPanelLauren Forums Analyst II Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    5,815
    Likes Received:
    443
    Trophy Points:
    233
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    Hi @Gareth-AWD

    Because FCGID has a different process handling method it may cover up the fact that connections weren't closing properly before. So the problem is most likely still there, just fcgid helps keep it maintainable due to its own configuration. I am glad though to hear things are resolved for you now.

    You can read in more depth about fcgid here: mod_fcgid - Apache HTTP Server Version 2.5

    Thanks!
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
  5. Gareth-AWD

    Gareth-AWD Well-Known Member

    Joined:
    Jul 3, 2008
    Messages:
    187
    Likes Received:
    6
    Trophy Points:
    68
    Location:
    London, UK
    cPanel Access Level:
    Root Administrator
    Hi Lauren,

    Thanks for clarifying it. Obvious concerned there may be an issue in the code somewhere. The code does check and create a new folder on the system with PHP mkdir and chmod, this is the only thing I can think of that may cause a wait issue? Is that something that may cause such an issue.

    It does odd thought the same code running on another server with suPHP does not exhibit the issue.
     
    cPanelLauren likes this.
  6. cPanelLauren

    cPanelLauren Forums Analyst II Staff Member

    Joined:
    Nov 14, 2017
    Messages:
    5,815
    Likes Received:
    443
    Trophy Points:
    233
    Location:
    Houston
    cPanel Access Level:
    DataCenter Provider
    Hi @Gareth-AWD

    My assumption based solely on the description of the issue is that it sounds a lot like the connections aren't being closed properly, this would leave them in the W state and is almost always a coding issue. If you're using the same code on a different server with the same configuration then it is quite possible it could be something entirely different. To find out though you'd most likely want to involve your system administrator. If you think it's something specific to cPanel, please feel free to open a ticket and add both the working + non-working servers so we can compare.
     
    Stop hovering to collapse... Click to collapse... Hover to expand... Click to expand...
Loading...

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice