# Tuning a Pack of Mongrels

> How to benchmark and determine the right number of Mongrel instances for your Rails app

- Author: Curtis Miller
- Published: 2007-06-19
- Categories: rails, ops, how-to
- Canonical URL: https://millarian.com/posts/tuning-a-pack-of-mongrels/

After having installed mongrel and mongrel\_cluster, I began reading the Tuning article (dead link: http://mongrel.rubyforge.org/docs/how\_many\_mongrels.html). This article is basically in response to people asking “How many mongrels should I have?” The quick answer is it depends.

The article talks about how to determine what you need because every situation is different. Some of the steps they talk about:

- Baseline your server by requesting a static file. If your site was entirely static content, then this is the performance you would get. Rarely is a site entirely static these days, but it gives you an idea about what you're shooting for.
- Run your tests multiple times. This allows for a warm up run and helps reduce the chance you're seeing anomalous behavior.
- Increase the number of connections until the test runs for 10 seconds.
- Add mongrel instances to your setup to see the rate increase/decrease. This allows you to tune into how many instances you need.
- Continuously measure against your benchmark. They use httperf.

The examples use [httperf](http://www.hpl.hp.com/research/linux/httperf) as a tool for adjusting the inputs and gathering the outputs of adding more mongrels, concurrent connections, etc. I did not have httperf installed on my Mac, but it seems that the [Apache HTTP server benchmarking tool](http://httpd.apache.org/docs/2.0/programs/ab.html) is already installed with OS X. You can find it and it's options by typing `man ab`. It gives you some pretty nice information and allows you to specify the number of concurrent connections, number of requests, etc.
