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!)
December 20th, 2008 at 9:14 am
Note that the 45 req/sec vs 1200 req/sec number is way off. It was probably done with Rails in development mode. Pratik ran some much better numbers (800 vs 3000 req/sec): http://weblog.rubyonrails.org/2008/12/20/performance-of-rails-metal
December 20th, 2008 at 9:21 am
Yeah, a wee bit unfortunate that. Had similar high hopes blasted with the Ruby Shootout announcement recently ;-)
Still, it's awesome nonetheless. I'll let your comment stand as the correction because there's little more authoritative than that!
December 20th, 2008 at 9:41 am
Probably would be a good thing to update the post as well. Otherwise you need to click through to see the correction and it's not going to show up in RSS either.
Metal is still awesome, though. It's just that Action Controller would be in a rough shape if it was only able to do 45 req/sec on hello world. So I'd rather just make sure that we don't let that number fester. 800 req/sec (or more accurately, 1.2ms) is a very respectable number for the pure run through the stack.
December 20th, 2008 at 9:50 am
Okay, okay, you've twisted my arm :)
October 3rd, 2009 at 8:35 am
Yeah, a wee bit unfortunate that. Had similar high hopes blasted with the Ruby Shootout announcement recently
February 1st, 2010 at 7:51 am
Hi,
Is there any Possibilities to use rake and metal in rails 2.2.?
Please any can help me ASAP.
Regards,
Bala
April 27th, 2010 at 10:28 am
Bala, it's impossible. Rack Middleware is here since Rails 2.3
I have had Rails 2.2 based Application, but rewrite this one to Rails 2.3.5 for night and really happy with Metal.
You can spend some time to do the same and your application will be easy to maintenance + all major advantages, like Rack middle application usage and Metal.