Worklog - Javascript frameworks, HTTP push, testing new features

A new batch of notes and links.

Javascript frameworks and selector engines

Ravelry development began over 2 years ago and I’m still using an older version of Prototype (1.5.1) and Scriptaculous. Upgrading is going to be a pain so I’ve put it off until I know where I really want to move to. I’m not convinced that jQuery is where I want to go from here and for now I’ve decided to wait until I see what the FuseJS guys have been up to. I’m hoping to move to something that helps me be less entangled in large Javascript frameworks and not more.

Old Prototype/Scripty hasn’t been a big deal because I tend to write new components from scratch rather than digging up plugins or add-ons that have dependencies. However, there have been tons of gains in CSS selector engine performance over the years and months (I’d call it an arms race, even) and faster selector engines = an all around better experience. Especially for IE users.

NWMatcher is currently the fastest of the fast. I plugged it in and it’s being tested on the site. Here is my diff for using NWMatcher with Prototype 1.5.1. It may be missing something - we just started testing it in production today: http://gist.github.com/241457

While making these changes, I discovered a really cool selector benchmark suite - SlickSpeed (see it in action). If you’ve got an Apache with PHP somewhere you can drop this in and easily benchmark whatever you are using against alternative frameworks/engines.

The thumbnail below shows what I’m currently using (Prototype 1.5ish) compared to 1.6 and 1.5 with NWMatcher dropped in. It’s small, but green is the fastest and red is the slowest :)

HTTP push/long polling with nginx

We used to use Lingr.com heavily for Ravelry help chat and group chats. When Lingr went offline, we added our own realtime AJAX/Comet chat to Ravelry. I put it together using Orbited and ActiveMQ and proxying to Orbited from nginx to avoid cross-domain/port Ajax. It worked.. mostly - but we often had to deal with browsers not reconnecting and ActiveMQ eating memory like mad. (ActiveMQ was used because it is the only Stomp message broker with authentication)

I was very happy to come across nginx_http_push_module last week. It handles simple message subscribing/broadcasting all inside of nginx. I was able to ditch Orbited and ActiveMQ, pop in the module, and move our chat over with only 30 lines of Javascript.

It’s nice to have something that I can build on in the future for other realtime Comet-like features. Our old setup was just too fragile for me to consider taking advantage of it for other uses.

Swatching

I do release new version of the site several times a week and sometimes I want to include features that are unfinished or totally experimental so that people can try them out, find bugs, and leave feedback.

These experiments can’t just be dropped into Ravelry. We have hundreds of thousands of users now and we can’t just treat everyone like guinea pigs anymore - I do have to make an effort to make sure that any changes are mostly bug-free and somewhat permanent and stable.

So… we have swatch codes. I post codes in a group for people who are interested in being guinea pigs and each code enables a not-quite-ready feature set. People add their choices to a special screen and I have a way to test to see if a code is enabled in both Ruby and Javascript. It’s not unlike what Google does with its “labs” section of Gmail.

This has been great for me - it really helps to get new ideas in front of people as soon as possible and with the swatchers, people aren’t too surprised or bothered when things appear, disappear, or break.

(Ravelers - check out http://www.ravelry.com/swatch)

Storage on the cheap

We needed a bunch of cheap storage for log files, locally stored backups and other archival data. For $640 I put together a simple 4 TB RAIDed NAS (well, 2 TB after RAID) that supports SFTP, rsync, and NFS. It’s just an empty Netgear ReadyNAS Duo ($250) with two 2 TB Western Digital disks. Setup was really easy: opened the box, screwed the disks into the carriers, put them in and waited to the RAID to initialize. It even looks cool.

Do your own research, of course. Some people have reported problems with the thing but I’m happy with it. Especially since it is just serving as a locally-attached backup and archival device for speed’s sake.