New to Rails 3? Check out the Ruby on Rails 3 Tutorial book and screencast.

A book and screencast series showing you how to develop and deploy industrial-strength Rails apps in a direct, step by step way. The screencast series includes 12 lessons over more than 15 hours! Get the best "over the shoulder" experience of following what a top Rails 3 developer does when building an app today. Click here to learn more.

Metal: Super-fast Endpoints within your Rails Apps

In Deployment, Elsewhere, Miscellaneous

aluminum.jpgYesterday, 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!)

Post to Twitter Tweet This Post

Vaguely Related Posts (Usually)

7 Comment Responses to “Metal: Super-fast Endpoints within your Rails Apps”

  1. #1
    DHH Says:

    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

  2. #2
    Peter Cooper Says:

    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!

  3. #3
    DHH Says:

    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.

  4. #4
    Peter Cooper Says:

    Okay, okay, you've twisted my arm :)

  5. #5
    mikeyaozm Says:

    Yeah, a wee bit unfortunate that. Had similar high hopes blasted with the Ruby Shootout announcement recently

  6. #6
    Bala Says:

    Hi,

    Is there any Possibilities to use rake and metal in rails 2.2.?

    Please any can help me ASAP.

    Regards,
    Bala

  7. #7
    mikhailov Says:

    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.

Leave a Reply