I’m still working on tweaking space paranoids so it is a bit meaner and leaner, and one thing I ran into this morning is that trac was crawling. I started looking at my options to see what I could do better.
First I tweaked apache a little bit to not use as much memory or threads on startup, which really didn’t help that much. Then I poked around with tracd, and that was incredibly faster than running it as CGI scripts through apache. The only problem was, I don’t want to run two daemons if I don’t have to, especially on port 80. Technically, I could have them both listen on different IP addresses, but I’d still have to do something funky like setup a subdomain for one of them, like trac.spaceparanoids.org. Meh.
lighttpd really isn’t an option for the same reason, though I’ve heard good things about it. I’d like to try it out some day, but for now I like apache a lot, and I’ll stick with that.
The next thing I wanted to try out was fastcgi. I had played with it before, but always had funky errors I couldn’t figure out with the environment variables. This time I actually read the documentation, and now all is well.
To set it up on Gentoo, this is all you have to do. Emerge trac with the ‘fastcgi’ use flag, and then also emerge mod_fastcgi. Add “-D FASTCGI” to /etc/conf.d/apache2 so it will parse and load /etc/apache2/modules.d/20_mod_fastcgi.conf. Then, setup your stuff for trac in your config files as you normally would. Since I’m using more than one trac installation, I have /trac pointing to the fcgi script directly with this: ScriptAlias /trac /var/www/spaceparanoids.org/cgi-bin/trac.fcgi
Finally, edit that trac.fcgi file manually (so sayeth the docs), and add these lines to the top:
import os os.environ['TRAC_ENV_PARENT_DIR'] = "/path/to/project/parent/dir"
Then I restart apache, and everything is running gloriously faster. I couldn’t be happier.
Of course, my SVN repositories still aren’t setup correctly, but I’ll fix that another day.