Overview — Phusion Passenger (a.k.a. mod_rails)

2 views
Skip to first unread message

Henry Maddocks

unread,
Apr 23, 2008, 12:26:14 AM4/23/08
to WellR...@googlegroups.com
Anyone played with this yet?

http://www.modrails.com/


Walter McGinnis

unread,
Apr 23, 2008, 12:46:03 AM4/23/08
to WellR...@googlegroups.com
Not yet, but I seriously have my eye on it for setting up boxes for shared hosting.

Cheers,
Walter

Philip Murray

unread,
Apr 23, 2008, 12:55:20 AM4/23/08
to WellR...@googlegroups.com
Yep, it's almost as awesome as advertised... some things about it some people don't seem to pick up straight away are:

It forks a process and loads all the Rails Framework (actually, it does this once per version of rails you're using) and your application into memory first, parsing your Ruby and storing the AST in memory.

Then for the processes that actually serve requests, it forks off processes from the one I mentioned above. What this means (at least on almost all *nixs) is that all the AST is only ever stored once in memory. This is because most OSs implement Copy-on-Write in regards to memory and forking. 

So, each version of of Rails (1.1.7, 1.2.6, 2.0.2, etc. etc.) and each application is only parsed and stored as AST once

This dramatically reduces the amount of memory used by your applications. Instead of just being 10x<your app here> like it is with a cluster of Mongrels. It also means forking extra children to serve requests is a lot faster. Then most of the memory usage is from allocating objects, RMagick leaks etc.


Cheers

Phil

Michael Koziarski

unread,
Apr 23, 2008, 1:02:22 AM4/23/08
to WellR...@googlegroups.com
> This dramatically reduces the amount of memory used by your applications.
> Instead of just being 10x<your app here> like it is with a cluster of
> Mongrels. It also means forking extra children to serve requests is a lot
> faster. Then most of the memory usage is from allocating objects, RMagick
> leaks etc.

This is *almost* true. You need to be running their COW friendly GC
patch for ruby, otherwise the mark-and-sweep garbage collector will
write to most of your pages.

>
> Just don't try it on FreeBSD 7
> (http://code.google.com/p/phusion-passenger/issues/detail?id=16)
>
> Cheers
>
> Phil
>
>
>
> On 23/04/2008, at 4:26 PM, Henry Maddocks wrote:
>
> Anyone played with this yet?
>
> http://www.modrails.com/
>
>
>
>
>
>
>
> >
>

--
Cheers

Koz

Philip Murray

unread,
Apr 23, 2008, 1:11:10 AM4/23/08
to WellR...@googlegroups.com
On 23/04/2008, at 5:02 PM, Michael Koziarski wrote:

>
>> This dramatically reduces the amount of memory used by your
>> applications.
>> Instead of just being 10x<your app here> like it is with a cluster of
>> Mongrels. It also means forking extra children to serve requests is
>> a lot
>> faster. Then most of the memory usage is from allocating objects,
>> RMagick
>> leaks etc.
>
> This is *almost* true. You need to be running their COW friendly GC
> patch for ruby, otherwise the mark-and-sweep garbage collector will
> write to most of your pages.


Which if anyone's interested can be downloaded from Github, not the
yet-to-be-created rubyenterpriseedition.com:

http://github.com/FooBarWidget/emm-ruby/tree/master

Tim Uckun

unread,
Apr 23, 2008, 12:51:48 AM4/23/08
to WellR...@googlegroups.com


I have. It's sweet!

I am testing a few rails apps on it. So far no problems although I did
have to tweak things a little.

If you are going to give it a whirl here is some useful info.

create two files for your /etc/apache2/mods-available directory

mod_rails.load
-----------------------
LoadModule passenger_module
/var/lib/gems/1.8/gems/passenger-1.0.1/ext/apache2/mod_passenger.so
RailsSpawnServer
/var/lib/gems/1.8/gems/passenger-1.0.1/bin/passenger-spawn-server
RailsRuby /usr/bin/ruby1.8
-------------------------

And

mod_rails.conf
--------------------

RailsDefaultUser your-web-server-user-name
RailsPoolIdleTime 600 #set this to whatever you feel comfortable
with. mod_rails will close the process to save memory after this many
seconds
RailsEnv production


in your /etc/apache2/sites-enabled create a file which has this

<VirtualHost *>
ServerName your.domain.name
DocumentRoot /var/www/application_name/current/public
</VirtualHost>


In your capistrano deploy.rb add this.

namespace :deploy do
task :start, :roles => :app do
end

task :stop, :roles => :app do
end

task :restart, :roles => :app do
run "touch #{release_path}/tmp/restart.txt"
end

task :after_update_code, :roles => :app do
run "rm -rf #{release_path}/public/.htaccess"
end
end

Now when you do cap deploy your code will be deployed on the server
and restarted.

Walter McGinnis

unread,
Apr 23, 2008, 5:44:39 AM4/23/08
to WellR...@googlegroups.com
I guess the thing I'm most specifically interested in is what alternative to send_file it provides (nginx's X-Accel-Redirect or lighty's X-Sendfile) for sending a file after authorization.

I would imagine Apache has something equivalent, but I wonder how to tie into it from my Rails app and if it would work ok with mod_rails.

Ideas?

Cheers,
Walter

Michael Koziarski

unread,
Apr 23, 2008, 5:48:02 AM4/23/08
to WellR...@googlegroups.com

Apache has a mod_xsendfile floating around too, which uses the same
header as Lighttpd.

--
Cheers

Koz

Walter McGinnis

unread,
Apr 23, 2008, 5:48:04 AM4/23/08
to WellR...@googlegroups.com
Found a partial answer in the comments to this post:


mod_xsendfile is the what Apache uses for this functionality...

Cheers,
Walter


Darryl Hamilton

unread,
Apr 23, 2008, 5:14:49 PM4/23/08
to WellR...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Henry Maddocks wrote:
> Anyone played with this yet?
>
> http://www.modrails.com/


I've had a quick play with this today. Mostly it's working nicely, but
I've come across a weird issue.

If I run it in 'production' mode, I get a method_missing error on a
standard AR find_by method in the application controller
(find_all_by_tag in this case). If I run in 'development' mode, I don't
get the error.

I might see if I can replicate it under a different app to see if it's a
common thing or if it's just this one.

Aside from that, it looks good, pretty close to mongrel in terms of
performance on individual requests. Will be interesting to see how it
handles under normal production loads.

Darryl.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.6 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQFID6bJ1ybsVgZckYURAo/HAJ9ZqcYmAND3bGPRZmzDgpPk3wTuKACdG4s7
FkHLMZZIo1WFxUKFIxHPnow=
=HZZb
-----END PGP SIGNATURE-----

Walter McGinnis

unread,
Apr 23, 2008, 5:22:49 PM4/23/08
to WellR...@googlegroups.com
Yep, that was what was alluding to in my links.  Looks like it should work.

Cheers,
Walter

nahum

unread,
Apr 23, 2008, 5:56:07 PM4/23/08
to WellRailed

I've not played with it, but have read an article (can't remember url)
comparing it's performance with mongrel and something else, Mongrel
came out on top. For us that's really important. I like the memory
saving though, that's pretty clever about things.


Nahum.



On Apr 24, 9:14 am, Darryl Hamilton <dar...@addict.net.nz> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Henry Maddocks wrote:
> > Anyone played with this yet?
>
> >http://www.modrails.com/
>
> I've had a quick play with this today. Mostly it's working nicely, but
> I've come across a weird issue.
>
> If I run it in 'production' mode, I get a method_missing error on a
> standard AR find_by method in the application controller
> (find_all_by_tag in this case). If I run in 'development' mode, I don't
> get the error.
>
> I might see if I can replicate it under a different app to see if it's a
> common thing or if it's just this one.
>
> Aside from that, it looks good, pretty close to mongrel in terms of
> performance on individual requests. Will be interesting to see how it
> handles under normal production loads.
>
> Darryl.
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.6 (GNU/Linux)
> Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org

Michael Koziarski

unread,
Apr 23, 2008, 6:08:16 PM4/23/08
to WellR...@googlegroups.com
> I've not played with it, but have read an article (can't remember url)
> comparing it's performance with mongrel and something else, Mongrel
> came out on top. For us that's really important. I like the memory
> saving though, that's pretty clever about things.

Don't underestimate the benefits of significantly reduced memory
usage. If you can run 8x processes in the space where 4x used to run,
you're instantly capable of handling twice the load (assuming you
weren't constrained by something other than number of processes).

Beside, it's cool to run thin or ebb or something now.

--
Cheers

Koz

nahum

unread,
Apr 24, 2008, 12:36:32 AM4/24/08
to WellRailed
I'll have to have a hunt for that url as it was proper load based
tests looking request times. So in that case the cleverness with
memory still wasn't enough to be quicker than mongrel. Only just
though, so given time....


Nahum.

Shane Mingins

unread,
Apr 24, 2008, 1:01:16 AM4/24/08
to WellR...@googlegroups.com
just saw this one in my newsreader
http://s2.diffuse.it/blog/show/53_Benchmarking+mod_rails+against+mongrel

--
Shane Mingins

Hongli Lai

unread,
May 1, 2008, 8:04:38 AM5/1/08
to WellRailed
On Apr 23, 11:56 pm, nahum <nahum.w...@gmail.com> wrote:
> I've not played with it, but have read an article (can't remember url)
> comparing it's performance with mongrel and something else, Mongrel
> came out on top.  For us that's really important.  I like the memory
> saving though, that's pretty clever about things.
>
> Nahum.

Actually, there are 2 articles at the moment which benchmark Passenger
vs Mongrel. Passenger comes out on top in both artciles, not Mongrel.

http://s2.diffuse.it/blog/show/53_Benchmarking+mod_rails+against+mongrel

and

http://izumi.plan99.net/blog/index.php/2008/03/31/benchmark-passenger-mod_rails-vs-mongrel-vs-thin/
Reply all
Reply to author
Forward
0 new messages