[Mongrel] Anyway to dynamically start/stop mongrel based on web traffic?

2007-01-10 Thread Philip Hallstrom
Hey all -

I've got a question that I haven't seen addressed anywhere and was 
wondering if anyone has put any thought into it or not...

Here's my setup... I have several *small* sites running apache/mongrel. 
Each has a single mongrel instance.  Most don't get any traffic (no one 
reads my blog :).

And I was thinking, I could host a couple of more sites/projects without 
worrying about ram if I could find a way have all my mongrels be off until 
a request came in... then apache (or some other server) could block until 
it could get mongrel started, then keep processing the request.

Then I could either kill off the mongrel later if no traffic was coming 
in.

Or perhaps mongrel itself could stay running, but unload (and free the 
ram) of rails until a request came in, then load it back up for awhile 
until traffic stopped and unload it...

So.. I guess I'm wondering if anyone's done anything like this or if it is 
possible and if so what the best way to go about it might be?  I'd be 
willing to help (if I can, but not sure how likely that is :)

It would be nice to have my little apps that get little traffic not suck 
up so much ram while idle..

-philip
___
Mongrel-users mailing list
Mongrel-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-users


Re: [Mongrel] Anyway to dynamically start/stop mongrel based on web traffic?

2007-01-10 Thread Jason LaRiviere
Philip Hallstrom wrote:
 Then I could either kill off the mongrel later if no traffic was coming 
 in.
 
 Or perhaps mongrel itself could stay running, but unload (and free the 
 ram) of rails until a request came in, then load it back up for awhile 
 until traffic stopped and unload it...

What you're talking about is inetd functionality for a rails process. If
you're on a sane unix, you could probably make that happen. Take a look
at /etc/inetd.conf, or your version thereof.

Whether it is a good idea or not, well, that's another matter. I'm
inclined to say not. :-)
-- 
GPG/PGP key ID: 0x3A410DBD | http://pgp.mit.edu
7B3F 4505 7D9A 7FDE 83C9  52C2 4909 59B9 3A41 0DBD
___
Mongrel-users mailing list
Mongrel-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-users


Re: [Mongrel] Anyway to dynamically start/stop mongrel based on web traffic?

2007-01-10 Thread Philip Hallstrom
 Philip Hallstrom wrote:
 Then I could either kill off the mongrel later if no traffic was coming
 in.

 Or perhaps mongrel itself could stay running, but unload (and free the
 ram) of rails until a request came in, then load it back up for awhile
 until traffic stopped and unload it...

 What you're talking about is inetd functionality for a rails process. If
 you're on a sane unix, you could probably make that happen. Take a look
 at /etc/inetd.conf, or your version thereof.

Kind of... my understanding of inetd though is that it listens on the 
port, accepts the connection, spawns the process and the process talks via 
stdin/out till done, then exits.

What I want is a front-end webserver that realizes mongrel isn't running, 
holds the connection while it starts it, then continues as normal.  I 
can kill the mongrel off later somehow...

Basically I want dynamically spawned FCGI processes, but I've used FCGI 
before which is why I'm now using mongrel :)

An ugly brute force would be to simply watch apache's logs for a 503 error 
and if seen start up mongrel, but that means one user is gonna get a 
broken page...

I don't know enough about mongrel/rails/ruby to know if mongrel can unload 
the majority of that 30mb it's using, but still keep on listening, but if 
someone (Zed? :) wanted to give me some pointers I'd love to give it a try 
:)

-philip
___
Mongrel-users mailing list
Mongrel-users@rubyforge.org
http://rubyforge.org/mailman/listinfo/mongrel-users