FcgidMaxProcessesPerClass Broken on Debian Squeeze

The server went down today with an out of memory kernel panic when Natural Jenius was under heavy load.  I started watching the system, and we were getting a separate php5-cgi process for each simultaneous request.  According to the Apache documentation, FcgidMaxProcessesPerClass is supposed to limit the number processes spawned per virtual host.  the default value is 100, but for a server our size it should be at about 2. So I fired up vi to edit the configuration.

$ cat /etc/apache2/mods-enabled/fcgid.conf
AddHandler fcgid-script .fcgi
 FcgidConnectTimeout 20
 FcgidMaxProcessesPerClass 2
$sudo service apache2 restart
 Restarting web server: apache2 ... waiting ...

I used the Apache benchmark tool from another machine to test the configuration. I started with twenty requests, five simultaneously.

$ ab -n 20 -c 5 naturaljenius.com/category/programming
This is ApacheBench, Version 2.3
Copyright 1996 Adam Twiss, Zeus Technology Ltd, http://www.zeustech.net/
Licensed to The Apache Software Foundation, http://www.apache.org/

Benchmarking naturaljenius.com (be patient)...apr_poll: \
    The timeout specified has expired (70007)

What the…? When I checked the server, there were a boatload php5-cgi processes, one for each request. The server was extremely slow and running out of RAM quickly.

Read the rest of this entry »