Question

I don't get it!

Rack: http://rack.rubyforge.org/

Rails Metal: http://weblog.rubyonrails.org/2008/12/17/introducing-rails-metal

I read the two articles and my eyes got blurry. How do the two components relate? Examples would be great?

Was it helpful?

Solution

Rack is a very lightweight specification that Ruby web servers can implement. It's middleware which means that it sits in between the web server (e.g. Passenger) and Rails.

Rails Metal is a way of processing an HTTP request using Rails for when you need the maximum performance. It virtually takes you down to the metal and bypasses all the normal features (and thus overhead) that the standard Rails' request/response cycle gives you. Technically, Rails Metal is an implementation of a Rack handler.

You might find these two Railscasts on the subject informative:

You can get a listing of the Rack middleware stack for a Rails application using rake middleware

OTHER TIPS

Rack is a generic Ruby API/layer of abstraction that lets different application frameworks integrate to a web server.

Rails Metal is Rails's implementation of a Rack handler. It includes not only a handler that calls Rails but also exposes its own API that makes it easier for you to create your own handlers that hit the web server and bypass core Rails.

There's a great discussion and a few examples on Jesse Newland's site:

So, essentially, Rails Metal is a thin wrapper around Rails’ new Rack middleware support. Rack middleware is pretty powerful stuff: framework-independent components that process requests independently or in concert with other middleware.

In addition to the differences covered by other folks, I wanted to note that a Rack app could be either middleware or a final endpoint while ActionController::Metal is always an endpoint an never middleware.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top