Apache using 100% CPU, once again

07
2014-07
  • CBenni

    Recently, apache2 started using 100% of CPU power: top gives me 100% cpu usage

    From other, similar threads, I took the tip to use mod_status. Aside from HUGE amounts of NULL requests, it gives:

    CPU Usage: u2.16 s1.32 cu0 cs0 - .0835% CPU load
    1.2 requests/sec - 17.6 kB/second - 14.6 kB/request
    8 requests currently being processed, 42 idle workers
    

    The access and error logs do not show anything surprising or intriguing at all.

    Note the .8% CPU usage. Another tip was to use strace:

    root@server:~# strace -p 1956
    Process 1956 attached - interrupt to quit
    restart_syscall(<... resuming interrupted call ...>
    

    And remains like this for at least half an hour, without producing any additional output. Restarting apache fixed the problem for less than a second The server runs a few custom python scripts aswell as a django-powered website on apache2 (up-to-date), but even turning the scripts off (or not having them active in the first place) did not change anything. After I stopped apache and powered my server off, powered it on a few minutes afterwards and restarted all my services, the CPU usage remained low for several hours, just in order to pop up again randomly (?)

    The DigitalOcean CPU stats on my server are: DigitalOcean stats You can see how the CPU usage was super high for almost half a day until I restarted the bot - just to remain stable for several hours and then pop up again.

    I am completely at a loss of words and don't know what I could do to find out what piece of my code is giving me these problems or if apache itself is the cause...

    Therefore I would greatly appreciate any hints to the questions: What else can I try to do? Which things might I not have checked? Is this definitely in my own code? How do you find what part of python code crashes an app via a infinite loop or similar?

  • Answers
    Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

    Related Question

    problems with Apache on Snow Leopard
  • Hristo

    I kind of screwed up the Apache "stuff" on my Mac. Usually when I visit http://localhost/, I would see the "It Works!" but now it just lists the directory and files inside /Library/WebServer/Documents.

    When I try to stop/start/restart the server with sudo apachectl stop, I get:

    httpd: Syntax error on line 68 of /etc/apache2/httpd.conf: Cannot load /usr/libexec/apache2/mod_disk_cache.so into server: dlopen(/usr/libexec/apache2/mod_disk_cache.so, 10): Symbol not found: _apr_file_info_get$INODE64\n  Referenced from: /usr/libexec/apache2/mod_disk_cache.so\n  Expected in: flat namespace\n in /usr/libexec/apache2/mod_disk_cache.so
    

    I don't want to do the MacPorts install, I tried it earlier but... I just want to do it via source code with the usual ./configure, make, make install.

    Any ideas on how to get this working? Is there a way to totally remove Apache and then reinstall a fresh version?


  • Related Answers
  • ChrisF

    I ended up backing up all of my files, erasing and re-installing Snow Leopard, and Apache was back to normal.