Apache 2.0 - 99% CPU - Random times

Discussion in 'Apache' started by sdsvtdriver, Dec 3, 2007.

  1. #1
    Hello,

    I'm running out of ideas with a problem on my box.

    Win2k3
    Apache 2.0.58
    php 4.4.7
    mysql 4.1.2.0

    At random times, I get notified that my sites are down. I rdesktop into the box and Apache is at 99% CPU time.

    Apache access logs show nothing of interest, nor does the error log.

    Windows event view shows nothing.

    The issue can last for 10 minutes or 2 hours.

    If I stop the Apache service and restart it, it pegs at 99% again within a few minutes.

    ideas?
     
    sdsvtdriver, Dec 3, 2007 IP
  2. James M

    James M Peon

    Messages:
    36
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #2
    post your keepalive settings (near top of apache config file)

    try "2" or "5" for KeepAliveTimeout

    in your php.ini try setting:
    session.save_handler = mm

    and maybe try:
    output_handler = ob_gzhandler
    (if some of your php sites dont work properly after setting this, comment it out and restart apache)

    these settings should help speed your machine up
     
    James M, Dec 5, 2007 IP
  3. SSANZ

    SSANZ Peon

    Messages:
    861
    Likes Received:
    10
    Best Answers:
    0
    Trophy Points:
    0
    #3
    The trouble is windoze imo;

    Good advice from James M, also check what pages / users are using most of the resources.
     
    SSANZ, Dec 5, 2007 IP
  4. tonybogs

    tonybogs Peon

    Messages:
    462
    Likes Received:
    13
    Best Answers:
    0
    Trophy Points:
    0
    #4
    There is something likely very wrong if Apache is hogging that much resource.

    I had an almost identical problem a few months ago and the error turned out to be in the NIC Card believe it or not. I ran a patch to update the drivers and it fixed it no worries.

    Hope this helps
     
    tonybogs, Dec 6, 2007 IP
  5. Ladadadada

    Ladadadada Peon

    Messages:
    382
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    0
    #5
    If you have a PHP script with an infinite loop it could cause this problem. There are plenty of other possible causes but this is the one I have seen most often in the wild.

    The first place I would start looking is in the Apache error log. Following that, I would look in the PHP error log. You could also try setting their log levels to "debug" to see if anything extra shows up.

    You could also try adding some code that marks a timestamp on disk whenever a script is started and marks a different one whenever the same script finishes. If you find one that starts and never finishes, then you have found the culprit.

    Try keeping a record of when the load is high with a script and look through the logs at the same time periods for patterns such as a bot crawling a particular set of pages.

    If none of those show up anything, try splitting the problem in half and testing both halves separately. For instance, you can split PHP out by using PHP in CGI mode rather than Apache module mode. This will show you whether it is Apache or PHP that is causing the problem.
     
    Ladadadada, Dec 8, 2007 IP