Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

Cramp: Asychronous Event-Driven Ruby Web App Framework

By Peter Cooper / January 7, 2010

got-the-cramp.pngCramp (GitHub repo)is a new, asychronous evented Web app framework by Pratik Naik of 37signals (and the Rails core team). It's built around Ruby's EventMachine library and was designed to use event-driven I/O throughout - making it ideal for situations where you need to handle a large number of open connections (such as Comet systems or streaming APIs.)

Out of the box, Cramp relies on Rails 3.0-pre's ActiveSupport and ActiveModel libraries (and won't work with earlier versions). Using these, it presents you with two layers to develop: controllers and models. Cramp controllers are ostensibly Rack compliant (Rack was designed primarily for synchronous scenarios) but Thin is currently the only HTTP daemon that can run Cramp apps due to its asynchronous app support.

Cramp models are built around a custom asynchronous MySQL-only ORM built on top of Arel and ActiveModel. Compared to the controllers, it seems to be at a very embryonic stage though it supports data methods like all, first, each, where, select, group, order, limit and offset. For basic CRUD functionality, it should do the job fine.

Pratik has a basic "hello world" example to show off the general structure of a Cramp app:


To learn more, read Pratik's Introducing Cramp blog post. He's presented a lot of examples to get you going.

Other Posts to Enjoy

Twitter Mentions