Rails performance and caching, part two

Over the weekend I continued to work on the performance of this website and saw some major (repeat major) improvements. Basically it turns out that while I had FastCGI properly set up I was not actually using it (which explains some other issues, like why the production flag wasn’t getting set). Turns out, earlier when I was testing FastCGI on my local machine I had edited the .htaccess file to point to the .fcgi file, but apparently this change was never committed to the repository, and thus I was using .cgi on the latest checkout on the server. A small oversight on my part, but then again this is an exercise for experience. So now that I’m properly using FastCGI here are some stats:

  • Plain pages before caching => ~0.18 seconds
  • Plain pages after caching (as fast as Apache can serve a static file)
  • Plain pages after caching with FastCGI (as fast as Apache can serve a static file)
  • Blog pages before caching => ~0.50 seconds
  • Blog pages after caching => ~0.02 seconds (25 times faster)
  • Blog pages after caching with FastCGI => ~0.01 seconds (50 times faster)
  • RSS feeds before caching => ~0.50 seconds
  • RSS feeds after caching => 0.009 seconds (55 times faster)
  • RSS feeds after caching => 0.003 seconds (167 times faster)

The CPU use is also way down. It no longer peeks on an individual request (which was caused by CGI loading the entire Rails Environment) and for the most part sits idle.

Finally, a second success this weekend was getting Switchtower working. Switchtower is a set of tools for automated deployment. You basically run a command from the root of your application folder like rake deploy and Switchtower will tunnel into your deployment machine (or machines, if your using a scaled setup with web, app, and db servers), checkout the latest version of your app, run any other tasks you’ve set up (for me I do some chmod-ing on caching folders), and then restarts everything. It works really well and is worth the short amount of time it takes to read the online manual and get your project set up. Switchtower has lot of other interesting features like easy rollback, atomic update support, and more. You can even use Switchtower for other projects, it’s not exclusive to Rails.

So that’s where I stand in Rails for now. This week I’ll be jumping back to PHP for some client apps and I have to say I’m starting to miss Rails when I do so. I’ll post more on this later as it’s something I imagine lots of people are dealing with. Till then…

Posted on: December 19, 2005 – 4:56 pm

Post a Comment | Comment RSS feed