# Need clarification on mongrel, rails, threads, and performance

**URL:** <https://www.ruby-forum.com/t/need-clarification-on-mongrel-rails-threads-and-performance/186860>\
**Category:** Rails\
**Created:** [April 13, 2010, 3:21pm UTC](https://www.ruby-forum.com/t/need-clarification-on-mongrel-rails-threads-and-performance/186860 "2010-04-13T15:21:25Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![skarayan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bbce88/32.png) [@skarayan](https://www.ruby-forum.com/u/skarayan)\
**Post date:** [April 13, 2010, 3:21pm UTC](https://www.ruby-forum.com/t/need-clarification-on-mongrel-rails-threads-and-performance/186860/1 "2010-04-13T15:21:25Z")

</div>

My understanding is that:

1. rails is single threaded and serves one request at a time
2. mongrel is single threaded and can process one rails request at a  
time
3. mongrel\_cluster starts a few mongrel servers on the same machine

Based on this, the single most important factor becomes the time it  
takes to load a single page (to avoid blocking).

If this is all true, what’s considered a “good” page loading time?

Thank you.

---

<div class="post-metadata">

**Author:** ![skarayan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bbce88/32.png) [@skarayan](https://www.ruby-forum.com/u/skarayan)\
**Post date:** [April 13, 2010, 3:28pm UTC](https://www.ruby-forum.com/t/need-clarification-on-mongrel-rails-threads-and-performance/186860/2 "2010-04-13T15:28:27Z")

</div>

On 13 April 2010 14:19, skarayan [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> My understanding is that:
> 
> 1. rails is single threaded and serves one request at a time
> 2. mongrel is single threaded and can process one rails request at a  
> time
> 3. mongrel\_cluster starts a few mongrel servers on the same machine
> 
> Based on this, the single most important factor becomes the time it  
> takes to load a single page (to avoid blocking).

Agreed. Consider Passenger though (as it’s easier to manage than  
Mongrels)  
or JRuby if you want multi-threaded serving.

> If this is all true, what’s considered a “good” page loading time?

That’s a “How long is a piece of string” type of question. I’d say aim  
for  
50-100ms, but it absolutely depends on what you’re doing. As long as  
the  
speed of page load given the amount of servers and traffic you have is  
acceptable for your users then don’t worry about it.

Benchmark, measure, improve/accept rather than ask for opinions - it  
really  
is the only way.

Cheers,

Andy

---

<div class="post-metadata">

**Author:** ![skarayan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bbce88/32.png) [@skarayan](https://www.ruby-forum.com/u/skarayan)\
**Post date:** [April 13, 2010, 5:04pm UTC](https://www.ruby-forum.com/t/need-clarification-on-mongrel-rails-threads-and-performance/186860/3 "2010-04-13T17:04:29Z")

</div>

I am trying to do some rough math:

Assuming 100ms per page, that’s about 10 requests per second.  
With 8 mongrels per cpu (based on suggestions on the web), that’s 80  
requests per second.

This seems like a very low request/second per machine.  
How are people getting 1000 or so requests per second? Is my math  
wrong?

What the average overhead by mongrel for cpu and ram?

Thank you.

---

<div class="post-metadata">

**Author:** ![skarayan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/bbce88/32.png) [@skarayan](https://www.ruby-forum.com/u/skarayan)\
**Post date:** [April 13, 2010, 5:17pm UTC](https://www.ruby-forum.com/t/need-clarification-on-mongrel-rails-threads-and-performance/186860/4 "2010-04-13T17:17:57Z")

</div>

On 13 April 2010 16:02, skarayan [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I am trying to do some rough math:
> 
> Assuming 100ms per page, that’s about 10 requests per second.  
> With 8 mongrels per cpu (based on suggestions on the web), that’s 80  
> requests per second.

I’d say 100ms should be the upper end, you’d want to be aiming for much  
faster than that but anyway.

> This seems like a very low request/second per machine.  
> How are people getting 1000 or so requests per second? Is my math  
> wrong?

High performance sites generally tend to use a lot of caching. Rails  
has a  
lot of caching mechanisms built in - page caching, partial caching,  
generic  
caching.

> What the average overhead by mongrel for cpu and ram?

No idea, I use Passenger. The overhead for Passenger is hard to  
determine,  
but my clients are happy with the performance so that’s what counts.

The best bet might be to see what percentage of your hits are to the  
homepage and each internal page type. Then setup a JMeter profile to  
hit  
pages in that ratio and see what you get. You can then try tweaking and  
caching. But find out your numbers before worrying about it - don’t  
guess  
at performance, measure!

Cheers,

Andy
