Because, Let's Face It, Webrick Sucks

Development Mode is for Smart People, Not for Webrick

When you run a Rails app in development mode, it's supposed to reload every single Rails file every time it's called for—in production, it caches stuff like your model classes, and an internal representation of the database table attached to the model. This makes development mode slow by nature, but really great when you're actually working on an app. The point of development mode is that you don't have to restart your web server just because you added a column to one of your database tables.

In development mode, though, it's not at all uncommon for Webrick to not reload files it should, or check out the database again like it should. Not only does it get progressively slower with each reload! No, on top of that, many of us have pulled out hair trying to figure out how our change isn't working, only to find it's because Webrick's not behaving and it needed to be restarted.

Basically, it's a crappy experience. Fairly unRails-like, even.

Enter Mongrel

Mongrel is another lightweight web server for Ruby apps, much like Webrick. Except it doesn't suck. Mongrel is so fast that it's actually good for parsing Ruby apps (like, I dunno, Rails!) on production servers.

Let me repeat myself:

Mongrel is Fast!

And it's easy to install:

$ sudo gem install mongrel

And it's easy to run in the background:

$ cd myrailsapp $ mongrel_rails start -d

It's also easy to stop:

$ mongrel_rails stop

Or run with its logging to your terminal window:

$ mongrel_rails start

Mongrel also runs on port 3000 so your Rails app should be available at http://localhost:3000/ if it's running on your current machine.

Zed Shaw is My Hero

He may be grumpy, but he made Mongrel and so he's secured himself a special place in my heart.

posted in: development, rails, tips and tricks    |     27 comments