Results 1 to 12 of 12
  1. #1
    Join Date
    Nov 2004
    Location
    New Jersey
    Posts
    108

    Server load, and tracing httpd processes

    I have a server that has server load showing at 25-40 (once it was even 53!), running like that for hours. The server has 4 cpus - and yet the sites on the server seem to run fine when I check them. What I'm wondering is, what exactly is load in this context; and how can load run so high like that without the server crashing?

    According to top, the load is caused by httpd processes running under user 'nobody', that often take up double digit CPU percentage.

    • Does Apache always run under 'nobody'?
    • Is there any way to trace an httpd processes - which account it's for, or which physical script or URL is calling it?


    And for top itself, the TIME field on one server of mine is in the format xx:xx (e.g. 3:25), on another it's TIME+ and in the format xx:xx.xx (e.g. 30:02.77). What exactly does this mean? I would asume it's minutes:seconds and minutes:seconds:hundredths, but while watching top it doesn't seem to correlate with that.

  2. #2
    Join Date
    Oct 2004
    Location
    Kerala, India
    Posts
    4,750
    Did you try checking apache status page?

    ps -ylC httpd --sort:rss

    From the above command you will get an idea of how much memory each thread is using, from the RSS column.
    David | www.cliffsupport.com
    Affordable Server Management Solutions sales AT cliffsupport DOT com
    CliffWebManager | Access WHM from iPhone and Android

  3. #3
    Join Date
    Nov 2004
    Location
    New Jersey
    Posts
    108
    Thanks for the reply, but I don't really care about the memory, the memory use % doesn't seem to be an issue. Just the cpu.

    I normally use ps -axuf|more, but that doesn't seem to give any additional details about httpd processes than top.

    And it looks like apache did eventually end up crashing due to the load, but it took a long while, and a simple restart fixed it.

  4. #4
    if it comes back, you could try enabling server-status with the ExtendedStatus in your httpd.conf file, then you can use your browser to view the server status.. this will associate the scripts and virtual host associated with the process.
    http://limehosting.com

  5. #5
    Join Date
    Jul 2003
    Location
    Goleta, CA
    Posts
    5,550
    Are you using an MPM with apache if you are using the 2x trees? If not consider using MPM Worker it's designed to be threaded which should work well on your 4 core server.

    That said it's also possible that it's a php script if you're running mod_php .
    Patron: I'd like my free lunch please.
    Cafe Manager: Free lunch? Did you read the fine print stating it was an April Fool's joke.
    Patron: I read the same way I listen, I ignore the parts I don't agree with. I'm suing you for false advertising.
    Cafe Owner: Is our lawyer still working pro bono?

  6. #6
    Join Date
    Nov 2004
    Location
    New Jersey
    Posts
    108
    I see that "ExtendedStatus On" is already present in httpd.conf, but I found documentation which said
    on every request Apache will perform two calls to gettimeofday(2) (or times(2), depending on your operating system). This is done so that the status report contains timing information. For highest performance, set ExtendedStatus Off (which is the default).
    Nothing about virtual host association. How does one approach the virtual host association using this directive?

    I don't believe MPM is enabled, where do I find out more about how to turn that on?

    And it should definitely be a PHP script, all sites are coded in PHP. I want to know how I can figure out which specific script(s) it is so I can deal with the issue by reprogramming or disabling the script or something.

  7. #7
    Join Date
    Dec 2002
    Location
    Quad Cities, Iowa
    Posts
    1,597
    If you have a httpd process that is consuming alot of CPU and running for quite a while, first make note of the process ID # and then run this:

    lsof | grep 20232 > output.txt

    20232 would be replaced with the actual process id.

    Then: nano -w output.txt

    Pay attention to the first 2 or 3 lines in that file, sometimes your able to see what script, or at least the directory of the script that is consuming the CPU.
    Need a new Web Host?
    Become a Host Refugee and receive TRUE 24/7 Support

    cPanel + Fantastico, PHP4 or PHP5
    HostRefugee.com - See our current promotions

  8. #8
    Join Date
    Nov 2004
    Location
    New Jersey
    Posts
    108
    Quote Originally Posted by HostRefugee-Vince View Post
    If you have a httpd process that is consuming alot of CPU and running for quite a while, first make note of the process ID # and then run this:

    lsof | grep 20232 > output.txt

    20232 would be replaced with the actual process id.

    Then: nano -w output.txt

    Pay attention to the first 2 or 3 lines in that file, sometimes your able to see what script, or at least the directory of the script that is consuming the CPU.
    Thanks, that was helpful.

    Anybody know about:
    • Does Apache always run under 'nobody'?
    • What units the TIME and TIME+ fields for top are in?
    • Anything about ExtendedStatus and virtualhost association?

  9. #9
    Does Apache always run under 'nobody'?
    Typically nobody is used, but Apache will run as whichever user you configure it for. You can explicitly specify a user to run httpd as through the User directive in httpd.conf:

    httpd.apache.org/docs/2.2/mod/mpm_common.html#user

    httpd will run as the user specified in the global User definition (outside of any virtualhost containers)

    • What units the TIME and TIME+ fields for top are in?
    • Anything about ExtendedStatus and virtualhost association?
    Your extendedstatus questions can be answered at:

    httpd.apache.org/docs/2.2/mod/mod_status.html

  10. #10
    Join Date
    Nov 2004
    Location
    New Jersey
    Posts
    108
    Thank you joeshacks and serverdoctor, server-status with ExtendedStatusOn showed exactly the info I was looking for! The Vhost and Request fields, which show the domain, and request details (e.g. domain.com, GET index.php) associated with a PID.

    And I found out this can be done from the command line with 'httpd fullstatus'.

    Though it seems Request details are truncated to 63 characters total. Anyone know if that can be changed?

    Also is there any way to view this with top's %CPU information? (the CPU column here is seconds)

  11. #11
    Join Date
    Nov 2004
    Location
    New Jersey
    Posts
    108
    Actually I'm not entirely sure what the CPU column in server-status is. It says "CPU usage, number of seconds", but it doesn't change as if it was seconds. What does it really mean?

  12. #12
    Join Date
    Nov 2004
    Location
    New Jersey
    Posts
    108
    Anybody know what the CPU column in server-status, and the TIME/TIME+ fields for 'top' actually mean?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •