# Estimating requests / sec

**URL:** <https://www.ruby-forum.com/t/estimating-requests-sec/126399>\
**Category:** Rails\
**Created:** [January 17, 2008, 11:55pm UTC](https://www.ruby-forum.com/t/estimating-requests-sec/126399 "2008-01-17T23:55:46Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![gustav](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/919ad9/32.png) [@gustav](https://www.ruby-forum.com/u/gustav)\
**Post date:** [January 17, 2008, 11:55pm UTC](https://www.ruby-forum.com/t/estimating-requests-sec/126399/1 "2008-01-17T23:55:46Z")

</div>

Hi;

We’re using Rails to serve dynamic data for a bunch of ads, which are  
going to be exposed about 3 million times/day.

To estimate the hardware setup, we’re trying to figure out what our peak  
load will be. They’ll be running on your average news/entertainment  
sites, anyone know of a somewhat good formula to guesstimate what our  
likely scenario is going to be?

Our best guess is that three peak hours (lunch+evening) will consume  
half of all queries. This would leave us with peaks at about 150 req./s.  
Sound good?

Also, I’ve been told/read that 40 req./s. is what to calculate for each  
Mongrel for a simple Rails app, does that seem reasonable?

Many thanks,  
Gustav

---

<div class="post-metadata">

**Author:** ![gustav](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/919ad9/32.png) [@gustav](https://www.ruby-forum.com/u/gustav)\
**Post date:** [January 18, 2008, 1:04am UTC](https://www.ruby-forum.com/t/estimating-requests-sec/126399/2 "2008-01-18T01:04:27Z")

</div>

Gu stav wrote:

> Hi;
> 
> We’re using Rails to serve dynamic data for a bunch of ads, which are  
> going to be exposed about 3 million times/day.
> 
> To estimate the hardware setup, we’re trying to figure out what our peak  
> load will be. They’ll be running on your average news/entertainment  
> sites, anyone know of a somewhat good formula to guesstimate what our  
> likely scenario is going to be?
> 
> Our best guess is that three peak hours (lunch+evening) will consume  
> half of all queries. This would leave us with peaks at about 150 req./s.  
> Sound good?
> 
> Also, I’ve been told/read that 40 req./s. is what to calculate for each  
> Mongrel for a simple Rails app, does that seem reasonable?
> 
> Many thanks,  
> Gustav

There are a lot of factors, like the hardware, other processes that are  
running, your architecture, etc. Your best bet may be to start  
relatively slow – like one client site – and see what your peaks are,  
where your bottlenecks are, iterate, and scale up as you go. You should  
pretty quickly be able to calculate your throughput and mongrel  
requirements.

---

<div class="post-metadata">

**Author:** ![gustav](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/919ad9/32.png) [@gustav](https://www.ruby-forum.com/u/gustav)\
**Post date:** [January 18, 2008, 1:50am UTC](https://www.ruby-forum.com/t/estimating-requests-sec/126399/3 "2008-01-18T01:50:20Z")

</div>

> Gu stav wrote:
> 
> > We’re using Rails to serve dynamic data for a bunch of ads, which are  
> > going to be exposed about 3 million times/day.
> > 
> > To estimate the hardware setup, we’re trying to figure out what our peak  
> > load will be. They’ll be running on your average news/entertainment  
> > sites, anyone know of a somewhat good formula to guesstimate what our  
> > likely scenario is going to be?

> There are a lot of factors, like the hardware, other processes that are  
> running, your architecture, etc. Your best bet may be to start  
> relatively slow – like one client site – and see what your peaks are,  
> where your bottlenecks are, iterate, and scale up as you go. You should  
> pretty quickly be able to calculate your throughput and mongrel  
> requirements.

Problem is that we can’t learn as we go, we get the full amount of  
traffic as soon as the ad hits the media channels, hence the need for  
some well educated guessing ;

---

<div class="post-metadata">

**Author:** ![gustav](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/919ad9/32.png) [@gustav](https://www.ruby-forum.com/u/gustav)\
**Post date:** [January 18, 2008, 5:27am UTC](https://www.ruby-forum.com/t/estimating-requests-sec/126399/4 "2008-01-18T05:27:45Z")

</div>

On Jan 17, 2008, at 7:04 PM, Jeremy Weiskotten wrote:

> > Also, I’ve been told/read that 40 req./s. is what to calculate for  
> > each  
> > Mongrel for a simple Rails app, does that seem reasonable?

In our experience, that _number_ would be about right, statistically,  
for several hundred running applications.

Some are less than 1 req/sec and others push beyond 80 req/sec.

However, those numbers are per _core_, not per Mongrel, and do not  
include DB server cores.

–  
– Tom M., CTO  
– Engine Y., Ruby on Rails Hosting  
– Support, Scalability, Reliability  
– (866) 518-YARD (9273) x201

---

<div class="post-metadata">

**Author:** ![gustav](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/919ad9/32.png) [@gustav](https://www.ruby-forum.com/u/gustav)\
**Post date:** [January 18, 2008, 5:41am UTC](https://www.ruby-forum.com/t/estimating-requests-sec/126399/5 "2008-01-18T05:41:11Z")

</div>

On Jan 17, 2008, at 8:26 PM, Tom M. wrote:

> Some are less than 1 req/sec and others push beyond 80 req/sec.
> 
> However, those numbers are per _core_, not per Mongrel, and do not  
> include DB server cores.

As noted in the original post, not all requests are created equal, so  
anything that can be intercepted and served statically can be turned  
around in a fraction of the time it takes to render a dynamic page.  
Even if it’s just assets that are served from an asset server, you’re  
way ahead of the game with that strategy. Caching infrequently used  
pages or fragments is a bonus if the application is shaped right for  
that.

---

<div class="post-metadata">

**Author:** ![gustav](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/g/919ad9/32.png) [@gustav](https://www.ruby-forum.com/u/gustav)\
**Post date:** [January 18, 2008, 5:44am UTC](https://www.ruby-forum.com/t/estimating-requests-sec/126399/6 "2008-01-18T05:44:09Z")

</div>

Here’s a simple formula to follow.  
A. Take the (average or median) request time, in seconds. Say, 0.250  
seconds (250ms)  
B. How many requests do you want to handle at peak? (e.g. 10,000 a  
minute, 166 a second)  
C. Multiply A x B : 0.250 \* 166 = 41.5

```
So you need about 40 mongrels to handle the load. At about 60MB per 

```

listener, that’s 2.4GB of RAM, plus a bit of room for leakiness  
and swapping. Ezra at Engine Y. suggest “about 10 dogs per CPU  
core”, which means that if we have a 4-core opteron box with 3GB of  
RAM, then this is possible on one box.  
Your mileage will vary, which means, if the box is lagging, remove a  
few mongrels.
