Mongrel w/Apache 2.0?

0 views
Skip to first unread message

pbe...@gmail.com

unread,
Jan 3, 2007, 12:18:30 PM1/3/07
to Ruby on Rails - Higher Ed.
We're looking to move to mongrel behind Apache. Our target platform is
RedHat Enterprise Linux 4, which means that we'll be running on apache
2.0.x until RHEL 5 comes out. This means that we don't have
mod_proxy_balancer built-in. Is anybody already running mongrel behind
Apache 2.0? Are you deploying with capistrano? Do you mind sharing
your setup?

Thanks,
Pat

Dan Reedy

unread,
Jan 3, 2007, 12:33:28 PM1/3/07
to ruby-on-rai...@googlegroups.com
I am currently running mongrel behind an Apache 2.0 using only
mod_proxy (not mod_proxy_balancer). I posted how I did this here:
http://railsforum.com/viewtopic.php?pid=1181

Dan Reedy

Dave Olsen

unread,
Jan 3, 2007, 1:07:12 PM1/3/07
to ruby-on-rai...@googlegroups.com
One addition for a production site you might want to add to the Apache
config is:

# Check for maintenance file and redirect all requests
RewriteCond %{DOCUMENT_ROOT}/system/maintenance.html -f
RewriteRule ^.*$ /system/maintenance.html [L]

If you do something like Capistrano you'll get the maintenance page
added automatically. Since we can't use Capistrano we manually rename
a file before upgrades. A screenshot of our maintenance page can be
found at: http://flickr.com/photos/dmolsen/323133760/

We picked up the config addition based on the example Mongrel
configurations at: http://mongrel.rubyforge.org/docs/apache.html


--

Proud supporter of DC United

Patrick Berry

unread,
Jan 3, 2007, 4:47:35 PM1/3/07
to ruby-on-rai...@googlegroups.com
What kind of load can one mongrel take?  I'm not looking to do anything too scary, just curious as to what our limits would be.  Most of the apps we do will be very lightly used.

Pat

On 1/3/07, Dan Reedy <danr...@gmail.com> wrote:



--
http://flickr.com/photos/pberry/
Cthulhu in 2008: 'Why settle for the lesser of two evils?'

Brian Hogan

unread,
Jan 4, 2007, 9:51:10 AM1/4/07
to ruby-on-rai...@googlegroups.com
Mongrel's load depends entirely on what your app is doing. The main thing you'll run into is locked requests. Rails is single-threaded so if you have a long user request (such as a user who uploads a large photo) then your app will make all other requests wait until he is done.

Look into testing your setup with httperf. You want to look at how many requests per second you can handle. If you need help doing perf testing with this tool, let me know.  You want to determine your baseline before you test your app. Hit up your public web site with httperf and see how many requests per second it can handle. 


httperf --server=www.example.com --num-conns=500


Now hit it with 10 simultaneous connections

httperf --server=www.example.com --rate=10 --num-conns=500

If you see the same number of requests per second (and no 500 errors) then increase the rate.

httperf --server=www.example.com --rate=20 --num-conns=500

Rinse and repeat.  Once you've found your threshold, run the same test for one of your Java apps, or PHP apps.... you'll eventually determine that static sites can serve anywhere from 100 to 1000 requests per second (depending on your setup).  You'll determine that dynamic sites and web applications tend to serve less than that.  Anywhere from 3 req/second to 100 req/sec depending on your setup, language, etc.

Once that's done, throw up one instance of mongrel on a higher port and hit it up with httperf. (There's an option for a port - see the docs).  See what that thing can handle. Then set up your cluster and start testing again.

Keep records of these tests so you can look back on them later, and be sure to run your tests from a different machine.   I also suggest taking httperf on a laptop and run the tests from outside your internal network, like from a cable connection or something so you can determine if there are limiting factors on the outside world. Nothing like spending weeks optimizing your system only to find out that your external users are throttled anyway.


If you don't have the ability to do mod_proxy_balance and you want to do some basic load balancing, look into Pen... easy to set up, even easier to run.  Pound is a good alternative but requires a configuration file for the balancing.   The drawback to using Pen or Pound is that you won't have a static web server to handle requests... that means that Mongrel will be handling all html / js / css requests.   I use Pen with several Mongrels and find it to be quite sufficient for the volume we handle... Mongrel is quite fast for handling static content, though a web server is much much faster. It all comes down to your needs, so do some tests!


Wow.. that was long. Hope that helps.

John Nunemaker

unread,
Jan 4, 2007, 10:45:05 AM1/4/07
to ruby-on-rai...@googlegroups.com
I didn't even ask the question but found it helpful. Thanks for the
good explanation.

~John

Reply all
Reply to author
Forward
0 new messages