Apache going crazy, eating all RAM

Discussion in 'Apache' started by dev22, Nov 20, 2009.

  1. #1
    hi,

    i have a problem with apache. it works perfectly fine, but once in a time, it goes crazy and consumes all RAM which causes swapping and then basically disabling the whole server. normally there is 1-2 GB free RAM. this started to happen way more often lately, basically ever 20 minutes.

    specs:

    dedicated server
    intel xeon 2.6 Ghz
    4 gb ram
    centos

    httpd -v:

    Server version: Apache/2.2.14 (Unix)

    any idea what can be causing this?
     
    dev22, Nov 20, 2009 IP
  2. sahabcse

    sahabcse Well-Known Member

    Messages:
    272
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    140
    #2
    check the log file and process info

    access log, error log etc.

    #sudo ps -ax | grep httpd
     
    sahabcse, Nov 22, 2009 IP
  3. vpslime

    vpslime Peon

    Messages:
    38
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    Sounds like your apache is spawning more servers/processes. It could also be a cronjob that spawns a script every min or more causing a domino effect with each process piling up on top of the other one.

    I'd start with looking at your 'prefork' settings and tune the server to consume a maximum amount of memory:

    Try these settings:
    <IfModule prefork.c>
    StartServers 64
    MinSpareServers 5
    MaxSpareServers 20
    ServerLimit 64
    MaxClients 64
    MaxRequestsPerChild 100
    </IfModule>
     
    vpslime, Nov 22, 2009 IP
  4. dev22

    dev22 Well-Known Member

    Messages:
    153
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    103
    #4
    i bought a new server at different host and it works fine now.

    looking at your config, i think the value is too big with startservers (i have it at 20). also, maxclients is too low, i need at least 200.
     
    dev22, Nov 28, 2009 IP