@madpilot makes

Using fcgid instead of fastcgi with Ruby on Rails

I have fallen victim to the fastcgi zombie process issue. It would seem that there is a problem with FastCGI running under apache2, where many zombie processes can not be killed, which eventually fills up the process table, slowing down the server. My guess is that is using up all of the sockets, thus stopping any other processes from taking connections (THis is speculation as I haven’t really investigated fully)

Any way – after a quick google, I found that other people have been successfully using the fcgid module, which is a binary compatible replacement for mod_fastcgi. Generic instructions can be found on this blog – however, the following instructions are suitable for Gentoo – it also allows you to use the .htaccess file, giving a finer site control:

  1. emerge mod_fcgid (I used the ACCEPT_KEYWORDS=”~x86″ to get the latest version)

  2. edit /etc/conf.d/apache – add the flag -D FCGID

  3. modify the virtual host in the apache.conf file to include:

Options ExecCGI

and

DefaultInitEnv RAILS_ENV production (For production mode obviously)

  1. modify /etc/apache2/modules/20_mod_fcgid.conf to include:

IPCCommTimeout 40
IPCConnectTimeout 10

(I put it immediately after the LoadModule directive)

  1. modify the A_ddHandler fastcgi-script .fcgi_ line in [Rails_app_root]/public/.htaccess to read:

AddHandler fcgid-script .fcgi

  1. Restart Apache.

I’ll keep you posted on whether it fixes the problem :)