# Webrick Development vs. Apache Server Speed

**URL:** <https://www.ruby-forum.com/t/webrick-development-vs-apache-server-speed/79406>\
**Category:** Rails\
**Created:** [December 14, 2006, 8:49pm UTC](https://www.ruby-forum.com/t/webrick-development-vs-apache-server-speed/79406 "2006-12-14T20:49:41Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![james](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@james](https://www.ruby-forum.com/u/james)\
**Post date:** [December 14, 2006, 8:49pm UTC](https://www.ruby-forum.com/t/webrick-development-vs-apache-server-speed/79406/1 "2006-12-14T20:49:41Z")

</div>

I’m prototyping a web app in RoR on my desktop machine  
(1.4ghz, 2gb ram) using webrick and mysql.

My application deals with a lot of data for some of our engineers to  
kind of cherry pick and filter, and then use to publish graphs.  
So I’m dealing with about 12,000 data points per graph.

It takes about 40 seconds for my query to the sql server (mysql) to  
complete.

Will switching from webrick to apache affect the speed of the query,  
assuming no hardware change?

Also, somewhat off topic, but can anyone ballpark for me the kind of  
hardware I’d need on a server (running apache/mysql, presumably fascgi  
(although I don’t know if that really matters)) to cut the query time  
down to ~4 seconds?

I know these are vague questions, and I’m just looking for ballpark  
answers to help make a feasibility judgement.

Thanks,  
James

---

<div class="post-metadata">

**Author:** ![james](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@james](https://www.ruby-forum.com/u/james)\
**Post date:** [December 14, 2006, 8:56pm UTC](https://www.ruby-forum.com/t/webrick-development-vs-apache-server-speed/79406/2 "2006-12-14T20:56:57Z")

</div>

James,

More than likely your query time is based on a lack of indexes. You  
may want to check to ensure that your database isn’t actually slowing  
you down instead of the rendering of your graph. Switching web servers  
will not help the speed of your query. You need to look at your  
datamodel and your indexing.

Carl

---

<div class="post-metadata">

**Author:** ![james](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@james](https://www.ruby-forum.com/u/james)\
**Post date:** [December 14, 2006, 8:58pm UTC](https://www.ruby-forum.com/t/webrick-development-vs-apache-server-speed/79406/3 "2006-12-14T20:58:57Z")

</div>

> It takes about 40 seconds for my query to the sql server (mysql) to  
> complete.

I would wager that something is wrong with your query.My guess is that  
you  
have not taken advantage of eager-loading.

Simple example:

Say a project belongs\_to :creator

I want to list all projects.

@projects = Project.find :all

Then I call @project.creator in a loop

@projects.each do |project|  
project.creator  
end

That causes one additional db hit for each iteration in the loop.

I should do

@projects = Project.find :all, :include=\>[:creator]

That will do a left-join for me, bringing in all projects and creator  
info  
into my objects. This is the #1 cause of slow Rails apps in my  
experience.

The second cause? Failure to properly index the database tables.

---

<div class="post-metadata">

**Author:** ![james](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@james](https://www.ruby-forum.com/u/james)\
**Post date:** [December 14, 2006, 9:55pm UTC](https://www.ruby-forum.com/t/webrick-development-vs-apache-server-speed/79406/4 "2006-12-14T21:55:04Z")

</div>

> Oh, I see now that I was misinterpreting my log file. The query is  
> taking less than one second to execute, and the rednering of the page is  
> taking the rest of the time.
> 
> Presumably this is related to the generation of the graph, and some  
> parsing of the data.
> 
> So I guess my question now degenerates to how hefty will my server  
> hardware have to be in order to speed up my execution time by about 10x?

Dont’ know, but every time this comes up someone says to look into  
background drb and offload the graph generation to it… then change  
your  
app to look to it with a “loading loading loading. done -\> show graph”  
setup.

Might be worth doing here as well…

---

<div class="post-metadata">

**Author:** ![james](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/bc8723/32.png) [@james](https://www.ruby-forum.com/u/james)\
**Post date:** [December 14, 2006, 9:12pm UTC](https://www.ruby-forum.com/t/webrick-development-vs-apache-server-speed/79406/5 "2006-12-14T21:12:33Z")

</div>

Oh, I see now that I was misinterpreting my log file. The query is  
taking less than one second to execute, and the rednering of the page is  
taking the rest of the time.

Presumably this is related to the generation of the graph, and some  
parsing of the data.

So I guess my question now degenerates to how hefty will my server  
hardware have to be in order to speed up my execution time by about 10x?

PS

Thanks Brian for your example, while this wasn’t the issue with my  
current application, I was doing what you pointed out in some of my  
other projects that I worked on at home while learning rails 🙂
