Metal: Super-fast Endpoints within your Rails Apps

Yesterday, David Heinemeier Hansson officially announced Rails Metal - a new feature of edge Rails (and so Rails 2.3). Metal uses edge Rails' use of Rack to present a more barebones interface to incoming requests. Instead of routing every request through the full Rails stack, Metal lets you circumvent it to respond to certain requests in a fast, lightweight fashion - ideal for polling requests, say.

DHH's summary is okay, but Jesse Newland's tour of Rails Metal really makes the concept click. He puts together a basic "Hello world" method in a regular Rails controller and one in Rails Metal. The Rails controller performs at 45 requests per second but the Rails Metal equivalent returns 1175 requests per second! David Heinemeier Hansson followed up with a more realistic benchmark where the Rails controller served 800 requests per second and Metal 3000 per second, though there's a little more to it as he explains..

An interesting side effect of Rails Metal is that you can now run Sinatra applications (and, potentially, those of similar micro frameworks) at full speed "within" a Rails application. Jesse gives an example of this, but the commit of interest is here. If Sinatra is of interest to you, check out Sinatra: 29 Links and Resources for a Quicker, Easier Way to Build Webapps over at Ruby Inside.

Support from: 1st Easy offers UK Rails hosting (dedicated and shared) running Phusion Passenger (mod_rails) and LAMP stack. If you want to get to know us first, or simply want to evaluate the performance of your Rails applications running on Passenger, we'll arrange a trial hosting account for you (full technical support included!)

Tweet This Post