MongrelCowCluster

by Eric Wong <[email protected]>
FIX (http://rubyforge.org/projects/mongrel-cow/)

DESCRIPTION:

A faster, Rails-only replacement for mongrel_cluster

Uses copy-on-write fork() to drastically reduce startup times when starting mongrel server. This means all of the Rails and environment code is read and loaded once and forked N times where N is the number of ports one wishes to bind to.

It is very similar to mongrel_cluster in use and can use config files generated for mongrel_cluster. This still creates pid and log files that are similar to those used by mongrel_cluster (mongrel.<port>.log and mongrel.<port>.pid).

All children are independent of each other and the death of one will not influence another. The parent process dies as soon as the final child is spawned.

Unlike traditional non-Ruby applications that use copy-on-write fork() to save memory, do NOT expect any significant memory savings even though this uses copy-on-write(), since the Ruby GC will trigger writes on whatever pages it marks. The main performance benefit of this is that the application code can be parsed once and reused.

If you connect to any other databases or services at Rails startup, you will need to re-init them manually. The default ActiveRecord::Base connection provided by Rails is disconnected after Rails is loaded and restarted/reconnected in each child process.

FEATURES/PROBLEMS:

Rolling restarts:

Although machines are all issued cow_cluster restart commands at
the same time (by Capistrano), each individual mongrel process
will be restarted independently of the others.  This means that
(assuming this works correctly :), only ONE mongrel process
per machine will be down at any given time.  This makes life
a lot easier for the Apache proxies (which will failover to
the next available port) and *should* be completely transparent
to the end user.

We now also check for successful startup of each individual port
by issuing an HTTP GET on "/" and report back to the person
running cow_cluster if that server has been successfully
started.

Daemonization is handled internally by cow_cluster since
Daemons::Daemonize (used by Mongrel) does too many things behind
our back wrt closing AR:B connections and redirecting log
files of the managing process.

SYNOPSIS:

Start:

mongrel_rails cow_cluster::start -C config/mongrel_cluster.yml

Stop:

mongrel_rails cow_cluster::stop -C config/mongrel_cluster.yml

Restart:

mongrel_rails cow_cluster::restart -C config/mongrel_cluster.yml

REQUIREMENTS:

gem_plugin >= 0.2.2
mongrel   >= 1.0.1

INSTALL:

sudo gem install mongrel_cow_cluster

LICENSE:

cow_cluster is copyrighted free software by Eric Wong <[email protected]>. You can redistribute it and/or modify it under either the terms of the GPL version 2 (see the file GPL), or the conditions below:

1. You may make and give away verbatim copies of the source form of the
   software without restriction, provided that you duplicate all of the
   original copyright notices and associated disclaimers.

2. You may modify your copy of the software in any way, provided that
   you do at least ONE of the following:

     a) place your modifications in the Public Domain or otherwise
        make them Freely Available, such as by posting said

modifications to Usenet or an equivalent medium, or by allowing the author to include your modifications in the software.

     b) use the modified software only within your corporation or
        organization.

     c) give non-standard binaries non-standard names, with
        instructions on where to get the original software distribution.

     d) make other distribution arrangements with the author.

3. You may distribute the software in object code or binary form,
   provided that you do at least ONE of the following:

     a) distribute the binaries and library files of the software,

together with instructions (in the manual page or equivalent) on where to get the original distribution.

b) accompany the distribution with the machine-readable source of

the software.

     c) give non-standard binaries non-standard names, with
        instructions on where to get the original software distribution.

     d) make other distribution arrangements with the author.

4. You may modify and include the part of the software into any other
   software (possibly commercial).  But some files in the distribution
   are not written by the author, so that they are not under these terms.

   For the list of those files and their copying conditions, see the
   file LEGAL.

5. The scripts and library files supplied as input to or produced as
   output from the software do not automatically fall under the
   copyright of the software, but belong to whomever generated them,
   and may be sold commercially, and may be aggregated with this
   software.

6. THIS SOFTWARE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
   IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
   WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
   PURPOSE.