Apache 2.4 not closing connections

6,492

I have found apache processes swelling (leaking memory) when they are re-used indefinitely it is worth setting a MaxRequestsPerChild 200 in your httpd.conf and restart.

Share:
6,492

Related videos on Youtube

Edi
Author by

Edi

Updated on September 18, 2022

Comments

  • Edi
    Edi almost 2 years

    I have an Apache 2.4 webserver that runs on a micro instance of AWS with CentOS.
    The apache is running PHP with a prefork MPM module.
    The server is accessed via an Amazon load balancer which has a health check that tries to access index.php webpage of the server every 60 seconds.

    The problem is that after 1-2 days, Apache reaches somehow 256 opened processes with index.php page and gives the following error:

    [Sun Sep 08 02:13:00.356051 2013] [mpm_prefork:error] [pid 1201] (12)Cannot allocate memory: AH00159: fork: Unable to fork new process
    [Sun Sep 08 02:13:13.656694 2013] [mpm_prefork:error] [pid 1201] AH00161: server reached MaxRequestWorkers setting, consider raising the MaxRequestWorkers setting
    

    Usually when this happens, new http connections are not accepted anymore.

    Apache probably doesn't close all the connections of the load balancer.
    We have another server with Apache 2.2, which doesn't have this problem, so probably the problem is with the 2.4 version which is much different than 2.2 (We didn't change any default configurations of Apache).

    mod_status is enabled and here is the output that we could get when this happened once: http://www.speedyshare.com/vE3My/server-status.txt

    Does anybody know how can we approach this problem?

    Thanks in advance!

    • Drew Khoury
      Drew Khoury almost 11 years
      What action did you take after reading that error?
    • shawnzhu
      shawnzhu almost 11 years
      It doesn't accept you TCP connections when httpd can't provide more child processes. Checkout the mpm_common, paste out <IfModule prefork.c> stanza and check number of your running httpd processes. you may need adjusting ServerLimit.
    • Edi
      Edi almost 11 years
      @DrewKhoury, I had to restart apache, I didn't have any other option.
    • Edi
      Edi almost 11 years
      @shawnzhu, The problem is not with the connection limit but with the fact that Apache reaches this limit. It should close these connections, but somehow it keeps them open.
    • iuri
      iuri over 9 years
      Have you found a solution? I'm experiencing the same problem with the same setup.
    • Edi
      Edi over 9 years
      Sorry that was a very long time ago, I don't remember what was the solution. If I remember right, we moved from micro instances to small and this was the change that solved the problem (micro instances on amazon tend to have large cpu steal time).