# Do i need multiple mongrel instances for good performance?

**URL:** <https://www.ruby-forum.com/t/do-i-need-multiple-mongrel-instances-for-good-performance/102025>\
**Category:** Rails\
**Created:** [August 9, 2006, 11:45am UTC](https://www.ruby-forum.com/t/do-i-need-multiple-mongrel-instances-for-good-performance/102025 "2006-08-09T11:45:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![chris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/958977/32.png) [@chris](https://www.ruby-forum.com/u/chris)\
**Post date:** [August 9, 2006, 11:45am UTC](https://www.ruby-forum.com/t/do-i-need-multiple-mongrel-instances-for-good-performance/102025/1 "2006-08-09T11:45:47Z")

</div>

I have developed a rails application for my company.

It will be used by upto 3o people at a time. I have just read that  
Mongrel will only process 1 request at a time (rails is only in 1  
controller at a time). Does this mean that to get good performance i  
need to run mongrel many times on different ports?

How many different instances of mongrel is recommended?

If this is true then it wouldn’t you agree it makes running mongrel a  
lot less simple than “mongrel\_rails start -pXXX”?

Also what is the simplest software to use that would allow me to run  
multiple instances all accessible from the same URL? How does it work?  
Do you assign 1 main port that all the other instances will be  
accessible from?

I am looking for the simplest solution.

Thanks  
Chris

---

<div class="post-metadata">

**Author:** ![chris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/958977/32.png) [@chris](https://www.ruby-forum.com/u/chris)\
**Post date:** [August 9, 2006, 3:07pm UTC](https://www.ruby-forum.com/t/do-i-need-multiple-mongrel-instances-for-good-performance/102025/2 "2006-08-09T15:07:41Z")

</div>

if you only have 3 people accessing the application, i probably  
wouldn’t worry unless you have a controller that takes a very long  
time to process. most requests are handled within milliseconds, so  
it’s really a non-issue.

if you do find yourself needing something more robust, take a look at  
mongrel\_cluster.

Chris

---

<div class="post-metadata">

**Author:** ![chris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/958977/32.png) [@chris](https://www.ruby-forum.com/u/chris)\
**Post date:** [August 9, 2006, 6:02pm UTC](https://www.ruby-forum.com/t/do-i-need-multiple-mongrel-instances-for-good-performance/102025/3 "2006-08-09T18:02:02Z")

</div>

This is a common question.

You’re correct: Rails can only handle one request at a time. HOWEVER,  
you  
have to know how long the reqest is. 30 people will most likey NOT be  
using  
the application at the SAME TIME because web apps connect you and then  
disconnect you. In the unlikely event that requests overlap, the users  
will  
just wait in line until the server can get to them.

You should run performance tests and determine your site’s capabilities  
in  
terms of ‘requests per second’

Your deployment platform makes a huge difference. One instance of  
Mongrel  
running on Linux can often be as performant as three instances of  
Mongrel on  
Windows.

Use httperf on Linux to test your URLs to see how many requests per  
second  
you can handle with your current server.

As for simplicity:

Mongrel\_cluster is a plugin that will let you set up multiple instances  
of  
Mongrel, each on its own port. You have to use Linux for this.

Pen is a simple load balancer that can link them together.

Say I have two instances of Mongrel running, one on port 4001 and one on  
port 4002;

To start listening on port 4000 with Pen, I just do

pen -r 4000 localhost:4001 localhost:4002

General rules apply here too… you need to optimize your application.  
Use  
page caching whenever possible (like pages which don’t need  
authentication)  
and use action or fragment caching whenever you can to reduce the  
request  
time. Ensure you’re eager loading data when appropriate to avoid  
unnecessary database access. Make sure you’re running in production  
mode so  
things run faster 🙂

And consult the community. We’ll help you out where we can.

Good luck to you!

---

<div class="post-metadata">

**Author:** ![chris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/958977/32.png) [@chris](https://www.ruby-forum.com/u/chris)\
**Post date:** [August 15, 2006, 2:18pm UTC](https://www.ruby-forum.com/t/do-i-need-multiple-mongrel-instances-for-good-performance/102025/4 "2006-08-15T14:18:38Z")

</div>

On Aug 9, 2006, at 5:30 AM, Brian H. wrote:

> General rules apply here too… you need to optimize your  
> application. Use page caching whenever possible (like pages which  
> don’t need authentication) and use action or fragment caching  
> whenever you can to reduce the request time. Ensure you’re eager  
> loading data when appropriate to avoid unnecessary database access.

With 30 users using it at once, even these steps are pre-  
optimizations. 🙂

–  
– Tom M.

---

<div class="post-metadata">

**Author:** ![chris](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/958977/32.png) [@chris](https://www.ruby-forum.com/u/chris)\
**Post date:** [August 15, 2006, 2:10pm UTC](https://www.ruby-forum.com/t/do-i-need-multiple-mongrel-instances-for-good-performance/102025/5 "2006-08-15T14:10:37Z")

</div>

On 8/9/06, Chris [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> lot less simple than “mongrel\_rails start -pXXX”?

[http://mongrel.rubyforge.org/index.html](http://mongrel.rubyforge.org/index.html)

Isak
