install the mongrel & mongrel_cluster gems

TO install the mongrel & mongrel_cluster gems.

$ sudo gem install mongrel mongrel_cluster --include-dependencies

mongrel_cluster is a gem plugin for mongrel that makes it easy to manage a cluster of
mongrels.

Lets configure our rails app to use it.
cd into your rails application’s root directory and run:

$ mongrel_rails cluster::configure -p 5000 -e production -a localhost

This will create the file:

$ cat config/mongrel_cluster.yml
---
num-procs: 1024
docroot: public
timeout: 120
cwd: /Users/ez/ez
log_file: log/mongrel.log
port: 5000
config_script:
debug: false
environment: production
servers: 6
pid_file: log/mongrel.pid
address: localhost

This is the config file that the cluster::configure just made. The only
thing I changed was the number of servers: which i set to 6.
Now lets start the mongrel cluster:

$ mongrel_rails cluster::start

You can now stop or restart the cluster with these commands:

$ mongrel_rails cluster::stop

OR

$ mongrel_rails cluster::restart

Then once the cluster is running we can fire up pen. This command runs
pen in debug mode in the foreground so you can see the requests being
handled by different mongrels. This is also using round robin technique. If you
turn off -d(debug) and -f(foreground) it will be a little bit faster
still.
$ sudo pen -r -a -f -d localhost:80 localhost:5000 localhost:5001 \
localhost:5002 localhost:5003 localhost:5004 localhost:5005 localhost:5005

With pen running in the foreground and debug mode like this you can see
pen balancing requests between our six mongrels. You will want to turn
off the -d and -f switches when you want to run in production.

you will need one IP address for each app you want to run. Or you can
put apache or any other server with this.




0 comments:

My Instagram