# Server performance with nginx and mongrel - can you compare?

**URL:** <https://www.ruby-forum.com/t/server-performance-with-nginx-and-mongrel-can-you-compare/68293>\
**Category:** Rails\
**Created:** [September 11, 2006, 2:55pm UTC](https://www.ruby-forum.com/t/server-performance-with-nginx-and-mongrel-can-you-compare/68293 "2006-09-11T14:55:42Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![dgm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/df788c/32.png) [@dgm](https://www.ruby-forum.com/u/dgm)\
**Post date:** [September 11, 2006, 2:55pm UTC](https://www.ruby-forum.com/t/server-performance-with-nginx-and-mongrel-can-you-compare/68293/1 "2006-09-11T14:55:42Z")

</div>

I just did test based on  
[http://blog.kovyrin.net/2006/08/28/ruby-performance-results/](http://blog.kovyrin.net/2006/08/28/ruby-performance-results/)

My server is:  
Athlon 2.66GHz, 1GB RAM  
Rails 1.1.6. + latest mongrel and nginx  
OS: CentOS 4.4  
Run in Rails production mode.

I have created application with test controller based on the article  
above. I have configured mongrel cluster with 4 backends and put nginx  
as frontend. Nginx configuration is based on Ezras article  
[http://brainspl.at/articles/2006/08/23/nginx-my-new-favorite-front-end-for-mongrel-cluster](http://brainspl.at/articles/2006/08/23/nginx-my-new-favorite-front-end-for-mongrel-cluster)

using following test:

# ab -n 1000 -c 100 [http://server/test/hw](http://server/test/hw)

gets me 55 req per second. I tried to change the number of mongrel  
backends but there was no imptact on speed at all. Is it normal? My  
another test page with simple scaffold item list from PostgreSQL on the  
same machine(30 items) cant get higher than 16 req/s on the same hw and  
configuration. The speed is the same if backend is one mongrel or 5.

Can someone share some real live experience?

Thanks,  
David

---

<div class="post-metadata">

**Author:** ![dgm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/df788c/32.png) [@dgm](https://www.ruby-forum.com/u/dgm)\
**Post date:** [September 11, 2006, 8:30pm UTC](https://www.ruby-forum.com/t/server-performance-with-nginx-and-mongrel-can-you-compare/68293/2 "2006-09-11T20:30:52Z")

</div>

On Sep 11, 2006, at 5:55 AM, David M. wrote:

> I have created application with test controller based on the article  
> another test page with simple scaffold item list from PostgreSQL on  
> the  
> same machine(30 items) cant get higher than 16 req/s on the same hw  
> and  
> configuration. The speed is the same if backend is one mongrel or 5.
> 
> Can someone share some real live experience?
> 
> Thanks,  
> David

Hey David-

```
Are you running ab from the same machine that you are testing? That

```

can seriously affect your results as ab takes up significant  
resources to do its thing. Try to run the ab test on another box on  
the same lan or local network. That being said, for your hardware and  
a hello world app that just does render :text=\> ‘hello world’ you  
should get better then 55. You should get closer to 100. Also start  
with one mongrel backend and get a baseline with concurrency of 10.  
Then up the concurrency and save the results. Then add another  
mongrel in and repeat. This way you start to see how much latency you  
have and how much req/sec you have.

```
Also keep in mind that even at 16req/sec you can serve 1,382,400

```

hits a day with the setup you just tested. Will you need to serve  
that many requests a day any time soon? 😉 So that is probably ok  
although it could be better. The other important thing to look at is  
the latency. How fast does your app _feel_ to the user. Concurrency  
measure your capacity, latency measure how long it takes for one  
response to complete. You can tweak the latency with some tricks to  
make the user feel like your site is fast if you need to.

Cheers-  
-Ezra

---

<div class="post-metadata">

**Author:** ![dgm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/df788c/32.png) [@dgm](https://www.ruby-forum.com/u/dgm)\
**Post date:** [September 12, 2006, 8:01am UTC](https://www.ruby-forum.com/t/server-performance-with-nginx-and-mongrel-can-you-compare/68293/3 "2006-09-12T08:01:00Z")

</div>

1. ab is running on other computer
2. I just did test with render :text=\> ‘hello world’  
a) connecting directly to one mongrel I got: 60 req/s . The same result  
when running through nginx  
b) I setup mongrel cluster with two mongrels and tried through nginx  
with proxypass. Got the same result atou nd 60req/s. The same situation  
when using Pound as mongrel frontend, so its not nginx issue.  
c) setup environment with 5 mongrels as cluster and nginx as frontend.  
No speed boost at all.

Cant get what can be a problem. When using ab on javascript file in  
rails instalation, nginx rule causes to file server directly and ommit  
the mongrel, I get 220 req/s.

PS: Latency seems to be good for SQL test, but its just for one user. I  
want to be sure that my users will not hang my server when running  
concurently.

David

Ezra Z. wrote:

> On Sep 11, 2006, at 5:55 AM, David M. wrote:
> 
> > I have created application with test controller based on the article  
> > another test page with simple scaffold item list from PostgreSQL on  
> > the  
> > same machine(30 items) cant get higher than 16 req/s on the same hw  
> > and  
> > configuration. The speed is the same if backend is one mongrel or 5.
> > 
> > Can someone share some real live experience?
> > 
> > Thanks,  
> > David
> 
> Hey David-
> 
> Are you running ab from the same machine that you are testing? That  
> can seriously affect your results as ab takes up significant  
> resources to do its thing. Try to run the ab test on another box on  
> the same lan or local network. That being said, for your hardware and  
> a hello world app that just does render :text=\> ‘hello world’ you  
> should get better then 55. You should get closer to 100. Also start  
> with one mongrel backend and get a baseline with concurrency of 10.  
> Then up the concurrency and save the results. Then add another  
> mongrel in and repeat. This way you start to see how much latency you  
> have and how much req/sec you have.
> 
> Also keep in mind that even at 16req/sec you can serve 1,382,400  
> hits a day with the setup you just tested. Will you need to serve  
> that many requests a day any time soon? 😉 So that is probably ok  
> although it could be better. The other important thing to look at is  
> the latency. How fast does your app _feel_ to the user. Concurrency  
> measure your capacity, latency measure how long it takes for one  
> response to complete. You can tweak the latency with some tricks to  
> make the user feel like your site is fast if you need to.
> 
> Cheers-  
> -Ezra

---

<div class="post-metadata">

**Author:** ![dgm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/df788c/32.png) [@dgm](https://www.ruby-forum.com/u/dgm)\
**Post date:** [September 12, 2006, 8:46am UTC](https://www.ruby-forum.com/t/server-performance-with-nginx-and-mongrel-can-you-compare/68293/4 "2006-09-12T08:46:19Z")

</div>

snacktime wrote:

> On 9/11/06, David M. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > Cant get what can be a problem. When using ab on javascript file in  
> > rails instalation, nginx rule causes to file server directly and ommit  
> > the mongrel, I get 220 req/s.
> 
> What’s the exact arguments you are feeding to ab? How many concurrent  
> requests are you testing with?

ab -n 1000 -c 10 [http://server/test/hw](http://server/test/hw)

---

<div class="post-metadata">

**Author:** ![dgm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/df788c/32.png) [@dgm](https://www.ruby-forum.com/u/dgm)\
**Post date:** [September 12, 2006, 3:25pm UTC](https://www.ruby-forum.com/t/server-performance-with-nginx-and-mongrel-can-you-compare/68293/5 "2006-09-12T15:25:00Z")

</div>

On Sep 11, 2006, at 11:01 PM, David M. wrote:

> No speed boost at all.
> 
> Cant get what can be a problem. When using ab on javascript file in  
> rails instalation, nginx rule causes to file server directly and ommit  
> the mongrel, I get 220 req/s.

220 req/s for a static file indicates some general performance problem  
on the server itself. This number is very low for modern hardware.

–  
– Tom M.

---

<div class="post-metadata">

**Author:** ![dgm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/df788c/32.png) [@dgm](https://www.ruby-forum.com/u/dgm)\
**Post date:** [September 12, 2006, 8:42am UTC](https://www.ruby-forum.com/t/server-performance-with-nginx-and-mongrel-can-you-compare/68293/6 "2006-09-12T08:42:09Z")

</div>

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

> Cant get what can be a problem. When using ab on javascript file in  
> rails instalation, nginx rule causes to file server directly and ommit  
> the mongrel, I get 220 req/s.

What’s the exact arguments you are feeding to ab? How many concurrent  
requests are you testing with?

---

<div class="post-metadata">

**Author:** ![dgm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/df788c/32.png) [@dgm](https://www.ruby-forum.com/u/dgm)\
**Post date:** [September 13, 2006, 1:39pm UTC](https://www.ruby-forum.com/t/server-performance-with-nginx-and-mongrel-can-you-compare/68293/7 "2006-09-13T13:39:12Z")

</div>

I installed the entire environment on another machine.  
PD4 2.8GHz, 2GB RAM, CentOS 4.4

with test:

# ab -n 1000 -c 100 [http://server/test/test1](http://server/test/test1)

I got around 250 req/s on following setup:  
nginx + 5 mongrels on background. Its amazing!!!

Thanks to all for the hints.  
David

Ezra Z. wrote:

> On Sep 12, 2006, at 6:15 AM, Tom M. wrote:
> 
> > > situation  
> > > 220 req/s for a static file indicates some general performance problem  
> > > on the server itself. This number is very low for modern hardware.
> > 
> > –  
> > – Tom M.
> 
> Also I have just posted a new nginx.conf file on my blog. Try this  
> one out to see if it helps you. This one has been perfected for rails/  
> mongrel. And it serves all static and rails cached files via nginx  
> _fast_ and then proxies the rest thru to mongrel cluster.
> 
> [http://brainspl.at/articles/2006/09/12/new-nginx-conf-with-rails-caching](http://brainspl.at/articles/2006/09/12/new-nginx-conf-with-rails-caching)
> 
> You should get _way way_ more then 220req/sec for static files.
> 
> Cheers-  
> -Ezra

---

<div class="post-metadata">

**Author:** ![dgm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/df788c/32.png) [@dgm](https://www.ruby-forum.com/u/dgm)\
**Post date:** [September 13, 2006, 9:00pm UTC](https://www.ruby-forum.com/t/server-performance-with-nginx-and-mongrel-can-you-compare/68293/8 "2006-09-13T21:00:08Z")

</div>

On Sep 13, 2006, at 4:39 AM, David M. wrote:

> Thanks to all for the hints.  
> David

Hey David-

```
Cool! I updated the config on my blog wigth a few more things like

```

correct headers sent to mongrel and it now handles the .js?23129391  
timestamped assets that rails makes. I also commented it for folks to  
know what does what. You should update

[http://brainspl.at/nginx.conf.txt](http://brainspl.at/nginx.conf.txt)

-Ezra

---

<div class="post-metadata">

**Author:** ![dgm](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/df788c/32.png) [@dgm](https://www.ruby-forum.com/u/dgm)\
**Post date:** [September 12, 2006, 6:47pm UTC](https://www.ruby-forum.com/t/server-performance-with-nginx-and-mongrel-can-you-compare/68293/9 "2006-09-12T18:47:29Z")

</div>

On Sep 12, 2006, at 6:15 AM, Tom M. wrote:

> > situation  
> > 220 req/s for a static file indicates some general performance problem  
> > on the server itself. This number is very low for modern hardware.
> 
> –  
> – Tom M.

```
Also I have just posted a new nginx.conf file on my blog. Try this

```

one out to see if it helps you. This one has been perfected for rails/  
mongrel. And it serves all static and rails cached files via nginx  
_fast_ and then proxies the rest thru to mongrel cluster.

[http://brainspl.at/articles/2006/09/12/new-nginx-conf-with-rails-caching](http://brainspl.at/articles/2006/09/12/new-nginx-conf-with-rails-caching)

```
You should get *way way* more then 220req/sec for static files.

```

Cheers-  
-Ezra
