# Apache2.2 + Mongrel: what do you think about these perfs?

**URL:** <https://www.ruby-forum.com/t/apache2-2-mongrel-what-do-you-think-about-these-perfs/98622>\
**Category:** Rails\
**Created:** [July 17, 2006, 12:09am UTC](https://www.ruby-forum.com/t/apache2-2-mongrel-what-do-you-think-about-these-perfs/98622 "2006-07-17T00:09:55Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![nauhaie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3ab097/32.png) [@nauhaie](https://www.ruby-forum.com/u/nauhaie)\
**Post date:** [July 17, 2006, 12:09am UTC](https://www.ruby-forum.com/t/apache2-2-mongrel-what-do-you-think-about-these-perfs/98622/1 "2006-07-17T00:09:55Z")

</div>

Hi all,

I’ve been spending quite a lot of time trying to install a decent RoR  
server on my dedicated server (Ubuntu 6.06 LTS), and now, everything  
works.

However, the performances are not really what I had expected… I would  
like to know what you think about it.

Here is my config: 2GHz VIA proc, 1Gb RAM, SATA-II HD.

I have apt-got ruby 1.8.4, mysql5 and installed rails 1.1.4 by means of  
rubygems (0.9.0). Then I installed the mysql extension (2.7}, mongrel  
(0.3.13.3) and mongrel cluster (0.2.0) and uploaded my app.

## Here is my mongrel\_cluster.yml:

port: “8000”  
environment: production  
pid\_file: log/mongrel.pid  
servers: 3

Then, I compiled Apache2.2. Here are my configure options:

./configure --prefix=/usr/local/apache2 --enable-modules=‘alias asis  
auth\_basic auth\_digest authn\_file authz\_user autoindex access cgi cgid  
charset\_lite dir env http imagemap include log\_config mime negotiation  
setenvif status deflate info proxy proxy\_balancer rewrite so headers’

Not too much, and static only… I don’t see how I could improve this…

Now, here is my vhost config:

\<VirtualHost \*\>  
ServerName dedibox  
DocumentRoot /home/noe/cukv3/public  
\<Directory “/home/noe/cukv3/public”\>  
Options FollowSymLinks  
AllowOverride None  
Order allow,deny  
Allow from all  
  
\<Proxy balancer://cukv3\>  
BalancerMember [http://127.0.0.1:8000](http://127.0.0.1:8000)  
BalancerMember [http://127.0.0.1:8001](http://127.0.0.1:8001)  
BalancerMember [http://127.0.0.1:8002](http://127.0.0.1:8002)  
  
ProxyPass /images !  
ProxyPass /stylesheets !  
ProxyPass /javascripts !  
ProxyPass / balancer://cukv3/  
ProxyPassReverse / balancer://cukv3/

The whole thing works, however, as I have said, I am not satisfied by  
the performances… Here is what I get for a middle-complexity action,  
which returns 10 articles from a given category (n-to-n relationship).  
(In fact, mysql’s CPU usage never gets \> 3%, so it is clearly ruby that  
slows it down…)

These benches have been realized with apache bench, from the box itself.  
So there is no delay due to the network. I know httperf is better, but I  
couldn’t manage to get it to work, because it took too much CPU.

So, here are the results:

1. Direct connexion to a mongrel server:

2. Through Apache2.2 and mod\_proxy\_balancer

Which seems to be unsufficient for production use…

So, what do you think? Is it normal? Did I do something wrong? In fact,  
I would be interested in points of comparison, and thoughts about these  
results.

Thank you very much!

Nauhaie

---

<div class="post-metadata">

**Author:** ![nauhaie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3ab097/32.png) [@nauhaie](https://www.ruby-forum.com/u/nauhaie)\
**Post date:** [July 17, 2006, 12:38am UTC](https://www.ruby-forum.com/t/apache2-2-mongrel-what-do-you-think-about-these-perfs/98622/2 "2006-07-17T00:38:51Z")

</div>

On Mon, 2006-07-17 at 00:09 +0200, Nauhaie wrote:

Everything looks fine from first glance.

\> \> 2.2) Static \> \> ab -n 100 -c 10 127.0.0.1/stylesheets/img/logo.gif \> Result: 1703 #/s

You should do one more test:

1. Create a small controller named “test\_controller.rb” and put an index  
action in it that render\_text “test” as the only thing it does.
2. Re-run your above test and see what kind of performance you get.

This is most likely your max Rails performance, if other pages aren’t at  
this level then you have to work on the Rails side to get them faster.  
If this measurement is the same as your /articles test then you’ve got  
something configured wrong since it has to be faster.

Check out ruby-prof as a way to get good performance tuning measurements  
for that specific action:

[http://rubyforge.org/projects/ruby-prof](http://rubyforge.org/projects/ruby-prof)

Specifically the part about using the ruby-prof library to measure one  
function.

–  
Zed A. Shaw

> **[Zed A. shaw](https://zedshaw.com/)**
>
> Personal essays and writings by Zed A. Shaw.

[http://mongrel.rubyforge.org/](http://mongrel.rubyforge.org/)  
[http://www.railsmachine.com/](http://www.railsmachine.com/) – Need Mongrel support?

---

<div class="post-metadata">

**Author:** ![nauhaie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3ab097/32.png) [@nauhaie](https://www.ruby-forum.com/u/nauhaie)\
**Post date:** [July 17, 2006, 12:32am UTC](https://www.ruby-forum.com/t/apache2-2-mongrel-what-do-you-think-about-these-perfs/98622/3 "2006-07-17T00:32:29Z")

</div>

Just as a sanity check, I have an under-development app that I switched  
over  
to production mode on a MacBook Pro (not the fastest server on earth)  
and  
httperf shows a single Mongrel serving up somewhere around 27 req/s for  
dynamic pages. Remember, this is a _laptop_ I’m benchmarking. Your  
server  
should outpunch it by a significant amount.

Nauhaie wrote:

> ab -n 100 -c 10 127.0.0.1:8000/articles/list?category\_id=2  
> Result: 5.70 #/s

–  
View this message in context:  
[http://www.nabble.com/Apache2.2-%2B-Mongrel%3A-what-do-you-think-about-these-perfs--tf1952024.html#a5353289](http://www.nabble.com/Apache2.2-%2B-Mongrel%3A-what-do-you-think-about-these-perfs--tf1952024.html#a5353289)  
Sent from the RubyOnRails Users forum at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![nauhaie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3ab097/32.png) [@nauhaie](https://www.ruby-forum.com/u/nauhaie)\
**Post date:** [July 17, 2006, 8:13am UTC](https://www.ruby-forum.com/t/apache2-2-mongrel-what-do-you-think-about-these-perfs/98622/4 "2006-07-17T08:13:34Z")

</div>

Hi!

> 1. Create a small controller named “test\_controller.rb” and put an index  
> action in it that render\_text “test” as the only thing it does.
> 2. Re-run your above test and see what kind of performance you get.

You are right, I should probably have done that in the first place…  
So, here are my results:

Direct to Mongrel:

ab -n 100 -c 10 127.0.0.1:8000/test ==\> 45#/s

Through Apache to 3 Mongrels:

ab -n 100 -c 10 127.0.0.1/test ==\> 45#/s, too

Does it seem you right?

Thank you!

Nauhaie

---

<div class="post-metadata">

**Author:** ![nauhaie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3ab097/32.png) [@nauhaie](https://www.ruby-forum.com/u/nauhaie)\
**Post date:** [July 17, 2006, 11:10pm UTC](https://www.ruby-forum.com/t/apache2-2-mongrel-what-do-you-think-about-these-perfs/98622/5 "2006-07-17T23:10:19Z")

</div>

If it might help, I have tried it with the same 3 Mongrels and Pound  
instead of Apache2.2 + mod\_proxy\_balancer.

I get 6.14 #/s (I had 6.38 with last config) with my script. With the  
simple Hello World, I get 40.86 (45 with last config). It appears that  
Pound is no better than Apache2.2… Can someone confirm that please?

I would really be interested in what performances you guys get, because  
I have pretty much nothing to compare with…

Thank you!

Nauhaie

---

<div class="post-metadata">

**Author:** ![nauhaie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3ab097/32.png) [@nauhaie](https://www.ruby-forum.com/u/nauhaie)\
**Post date:** [July 18, 2006, 12:02am UTC](https://www.ruby-forum.com/t/apache2-2-mongrel-what-do-you-think-about-these-perfs/98622/6 "2006-07-18T00:02:19Z")

</div>

Ok thank you. I will try to see what I can do. At least, I am glad my  
configuration is ok 😉

Nauhaie

---

<div class="post-metadata">

**Author:** ![nauhaie](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/n/3ab097/32.png) [@nauhaie](https://www.ruby-forum.com/u/nauhaie)\
**Post date:** [July 17, 2006, 11:37pm UTC](https://www.ruby-forum.com/t/apache2-2-mongrel-what-do-you-think-about-these-perfs/98622/7 "2006-07-17T23:37:31Z")

</div>

On Mon, 2006-07-17 at 23:10 +0200, Nauhaie wrote:

> If it might help, I have tried it with the same 3 Mongrels and Pound  
> instead of Apache2.2 + mod\_proxy\_balancer.
> 
> I get 6.14 #/s (I had 6.38 with last config) with my script. With the  
> simple Hello World, I get 40.86 (45 with last config). It appears that  
> Pound is no better than Apache2.2… Can someone confirm that please?
> 
> I would really be interested in what performances you guys get, because  
> I have pretty much nothing to compare with…

Yep, basically you’re putting your efforts in the wrong place. If you  
run a test controller and you get 40.86, and then your page gets 6.14,  
then changing out the balancer will do absolutely nothing for you.  
You’ve got to work on making your rails actions faster. Nothing can  
save you. You’re doomed. Time to work on the real problem. 🙂

Check out ruby-prof for some hints, also look at some earlier posts by  
Stefan K. and Scott B. for other tools. Otherwise, just keep  
benching and tweaking until you find out the problem. Your  
production.log is the key to your problem.

–  
Zed A. Shaw

> **[Zed A. shaw](https://zedshaw.com/)**
>
> Personal essays and writings by Zed A. Shaw.

[http://mongrel.rubyforge.org/](http://mongrel.rubyforge.org/)  
[http://www.railsmachine.com/](http://www.railsmachine.com/) – Need Mongrel support?
