Apache is freezing CPU

Discussion in 'Apache' started by rubenyc, Sep 1, 2008.

  1. #1
    We have a server with more or les 30K daily pageviews with 6k unique users. Its content is mainly all dynamic but lately we've been experimenting some problems at peak hours.

    That's some of our info:

    Celeron® 2.0GHz Processor
    1 GB RAM

    Timeout 120
    KeepAlive On
    MaxKeepAliveRequests 100
    KeepAliveTimeout 2

    <IfModule prefork.c>
    StartServers 8
    MinSpareServers 5
    MaxSpareServers 20
    ServerLimit 256
    MaxClients 256
    MaxRequestsPerChild 4000
    </IfModule>

    <IfModule worker.c>
    ServerLimit 256
    StartServers 2
    MaxClients 150
    MinSpareThreads 25
    MaxSpareThreads 75
    ThreadsPerChild 25
    MaxRequestsPerChild 0
    </IfModule>

    I think that we shouldn't have the problems we have, it's not that much visits!

    Please advise... we've tried tons of configurations and we don't know what it could be... Or maybe it's not apache...

    Thanks!
     
    rubenyc, Sep 1, 2008 IP
  2. LH-Danny

    LH-Danny Guest

    Best Answers:
    0
    #2
    I think you should hire yourselves a Server Admin to have a look.
     
    LH-Danny, Sep 1, 2008 IP
  3. rubenyc

    rubenyc Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I think I'm posting this because I wanna try to fix it by myself if it's possible :)
     
    rubenyc, Sep 1, 2008 IP
  4. LH-Danny

    LH-Danny Guest

    Best Answers:
    0
    #4
    Edit your httpd.conf file

    Then set the following values as shown below:

     
    LH-Danny, Sep 1, 2008 IP
  5. The Universes

    The Universes Peon

    Messages:
    187
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #5
    How many concurrent connections are you getting at peak?
     
    The Universes, Sep 1, 2008 IP
  6. rubenyc

    rubenyc Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #6
    Thanks for your replies... I have changed the settings for what LH-Danny said and still freezes when the server has more or less 150 users at the same time.

    Now I'm having this

    CPU Usage: u6.72 s1.74 cu0 cs0 - 6.18% CPU load
    25.3 requests/sec - 118.8 kB/second - 4814 B/request
    256 requests currently being processed, 0 idle workers

    WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
    WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
    WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW
    WWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWWW

    Any ideas?

    Thanks again, I really appreciate it.
     
    rubenyc, Sep 1, 2008 IP
  7. LH-Danny

    LH-Danny Guest

    Best Answers:
    0
    #7
    Next time during peak hours, run the top command and paste it here. That way I can see what is freezing your CPU. Apache should be running ok tbh.
     
    LH-Danny, Sep 1, 2008 IP
  8. GeorgeP

    GeorgeP Peon

    Messages:
    37
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #8
    post more info:
    aka running mysql on same machine?
    any specially compiled modules/kernels/patches ?
    any log entrys? memory leaks?
     
    GeorgeP, Sep 1, 2008 IP
  9. rubenyc

    rubenyc Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    Hi all! Thanks for your help!

    George:

    aka running mysql on same machine? YES
    any specially compiled modules/kernels/patches ? NO
    any log entrys? memory leaks? LOGS ARE FINE. MYSQL SLOW LOG is also fine, we fixed this a while ago.

    Here I attach a screenshot of top, but after running the command ab to stress the server. Looks like mysql is consuming CPU dramatically. Maybe it's a problem of MySQL? Any advise on this? Now we have a dedicated server with both apache and mysql running. Is that normal?

    [​IMG]

    Any help would be really appreciated.
     
    rubenyc, Sep 1, 2008 IP
  10. The Universes

    The Universes Peon

    Messages:
    187
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #10
    Use mytop to look at what queries are taking a long time to complete.
    Basically, you will need to optimize your mysql config (my.cnf) but more importantly, you need to optimize your scripts to be more efficient in querying (use caching, indexes are properly utilized, etc).

    If you have a dedicated machine for running MySQL, it will be faster. A faster CPU than the Celeron will also give you better MySQL performance.
     
    The Universes, Sep 1, 2008 IP
  11. rubenyc

    rubenyc Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #11
    The Universes thanks for the mytop hint! I didn't know that program!!! But all the queries are pretty fast, they take less than a second to complete...

    The screenshot I attached was after running the command ab to stress the server, that's maybe why mysqld is so cpu consuming. Is it normal?
     
    rubenyc, Sep 1, 2008 IP
  12. rubenyc

    rubenyc Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #12
    This it top when it doesn't load any page (now I'm not using apache bench)

    [​IMG]

    And this is when it has a lot of users, but it still works, I guess before crashing

    [​IMG]
     
    rubenyc, Sep 2, 2008 IP
  13. The Universes

    The Universes Peon

    Messages:
    187
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #13
    The last two top printouts show a lot of iowait, which is causing your load averages to shoot up.
    It looks like your swapping a lot, which will cause that.
     
    The Universes, Sep 2, 2008 IP
  14. rubenyc

    rubenyc Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #14
    And what's a possible solution to prevent that?

    Thanks
     
    rubenyc, Sep 2, 2008 IP
  15. The Universes

    The Universes Peon

    Messages:
    187
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #15
    Reduce RAM usage (use top to find out what program is hogging it) or add more RAM.
    From the looks of it, you have a lot of Apache child procs when it happens, meaning theres quite a few concurrent users at that time. You might want to look into optimizing the httpd.conf some more, taking out modules that you don't use to reduce memory usage. Otherwise, something like Lighttpd is much more suitable for high number of concurrent connections and low memory footprint.
     
    The Universes, Sep 2, 2008 IP
  16. Abid Anwar

    Abid Anwar Peon

    Messages:
    39
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #16
    i think you can use IISA in the place of APCHI web server. this webserver is more effective then APCHI. and it should resolve your problem.regards.
     
    Abid Anwar, Sep 4, 2008 IP