Acorns

Marcel's blog

Riding Rails with Typo

I upgraded from my home-brew XSLT-based static blog to Typo with the main goals of getting robust comment features and getting to tinker with a Rails app. Along the way, I also tried to support the original blog's URLs, article IDs, and look-and-feel. And I checked that it would deliver pages reasonably quickly.

Comments

The comment feature is great. There are a number of anti-spam measures, a comment moderation system, and comment feeds. I can't wait to use the features for real.

Customization

Customizing Typo was a snap. Thanks to Rails plugins, I was able to add routes to support the legacy URL structure, a common requirement for any web application upgrade.

I had to write my own short script to import existing blog entries from the Atom feed, but the ActiveRecord and REXML APIs made that fairly easy. Two hangups were Rails not letting me back-date the created_at and updated_at timestamps, and getting the timezone right on all timestamp fields, which were created in Postgresql without timezones.

I had to tweak the Atom template to avoid the "urn:uuid" prefix on the existing blog entry Atom IDs, but thanks to Typo's theme system, I was able to do that without editing any template files in the Typo distribution. The look-and-feel was just a matter of adapting the CSS in the Scribbish theme. Those enchancements can be found in this Oak Savannah theme.

Performance

One of my biggest worries was that Rails wouldn't perform well on my low-power server. It's only got 160MB of RAM, nearly all used even without Rails. Mongrel starts with about 37MB. So far, running in production mode, it consistently takes about 0.3 sec for the first request after sitting idle for a while and 0.07 sec for subsequent requests, according to ApacheBench. And a cached home page can load with just 10MB of resident memory. That's tolerable. But once in a while, the process seems to get pushed out of memory and takes about ten seconds to deliver a page with much swapping. I'm still working out why that happens, but the real solution is probably to get more RAM.

I'm pleased with the suggested reverse HTTP proxy integration with Apache: when everything's swapped in to memory, it adds only about 10% overhead to page delivery time in ApacheBench.

It's no surprise that Typo can't serve pages as fast as the static files I had Apache serving under the old system. But still, on my meager hardware, server-side performance and swapping are the biggest areas for improvement of my installation.

Other Issues

There are a couple more issues besides server performance. First, according to Firebug, 128KB of Javascript and CSS, mostly prototype.js and effects.js, get loaded on every page. The browser never caches them, probably because of the query string, which contains the file's modification timestamp. For a lot of people that will mean a few extra seconds of perceived page load time.

The second issue is that the Sitealizer stats have some hard-coded URLs that make it incompatible with Mongrel's --prefix option. I use this option to get Mongrel to move the whole Typo application from / to /~marcel/blog so that all the links come out right. (Well, actually, it has to be /%7Emarcel/blog to make Mongrel happy.)

Overall, I'm very pleased with the features, which were my main reason for switching to Typo, and I'm thrilled to have an excuse to run a Rails app for real.

Post a comment

Name or OpenID (required)


(lesstile enabled - surround code blocks with ---)