I've been running Apache 1.3.x with mod_fastcgi for almost a year and a half and it's been a very stable combination. I could restart apache with
apachectl graceful
and fcgi manager would send USR1 signal to all fastcgi children.
This mechanism is completely broken with Apache2. When I restart apache, for some reason it sends the signal only to one of its fastcgi children, the rest remain in memory doing nothing. Unfortunately, it seems that mod_fastcgi is not being actively maintained now.
Welcome mod_fcgid!. According to the mod_fcgid website:
mod_fcgid has a new process management strategy, which concentrates on reducing the number of fastcgi server, and kick out the corrupt fastcgi server as soon as possible.
The default parameters are pretty much aggressive in terms that fcgid would kill children that were idle for more than 5 minutes and it would always kill those that lived more that 1 hour. This is not exactly what I want for my long running Rails dispachers. I've been tweaking configuration options until I came up with:
AddHandler fcgid-script .fcgi
SocketPath /var/lib/apache2/fcgid/sock
IPCCommTimeout 120
IPCConnectTimeout 10
MaxProcessCount 40
ProcessLifeTime 86400
IdleTimeout 1800
DefaultMaxClassProcessCount 8
DefaultInitEnv RAILS_ENV production
Now I can freely use apache2ctl graceful to restart my application without worrying that there might be some processes left wasting memory. Also this gives me ability to use Capistrano to automate my deployment process. Check it out, it rocks!