I was setting up a Debian system running Apache 2.2.3. I installed libfcgi-ruby and libapache2-mod-fcgid. I got that set up, enabled the mod, made an alias to the rails directory, and setup the .htaccess file. However, I was unhappy that my rails applications were terribly slow! There was a pause of 2-5 seconds for every request. Since this was just internal development I figured it was okay. Other hosts worked just fine, so I figured it was something strange about this particular configuration and I had other things to do.
Like any itch you try to ignore, this one only got worse. So today I decided to go over my configuration and figure out what was wrong. All the files are there; the modules are loaded; no strange log messages; how odd. I watched top while reloading a page and my dispatch.cgi just disappeared after the request. It was as if I was running it as a CGI process.
Wait a minute, like a CGI process? Let me see that .htaccess again. That was where I saw it:
RewriteRule ^(.*)$ dispatch.cgi [QSA,L]
Oooooh! Duh. I hadn't pointed the .htaccess file at the fcgi script, so I was running it as a CGI process and it was having to load ruby and the script for every request. No wonder it was slow. I did a quick swap to,
RewriteRule ^(.*)$ dispatch.fcgi [QSA,L]
What a difference a single letter can make. It zips long happily now and I once again betray my ignorance.