# Deploying in Production Level (Ideas please)

**URL:** <https://www.ruby-forum.com/t/deploying-in-production-level-ideas-please/117239>\
**Category:** Deployment\
**Created:** [October 15, 2007, 6:46am UTC](https://www.ruby-forum.com/t/deploying-in-production-level-ideas-please/117239 "2007-10-15T06:46:26Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![ace](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/848f3c/32.png) [@ace](https://www.ruby-forum.com/u/ace)\
**Post date:** [October 15, 2007, 6:46am UTC](https://www.ruby-forum.com/t/deploying-in-production-level-ideas-please/117239/1 "2007-10-15T06:46:26Z")

</div>

Dear All,

I just started using rails.  
After surfing and reading a lot I need some feedback from you guys.  
In production level what is the best configuration to use Rails with  
maximum performance. Correct me if I am wrong please.

1. Ruby on Rails, with lighttpd/mongrel, a database
2. Ruby on Rails, mod\_ruby with Apache2, a database
3. Ruby on Rails, FastCGI with Apache2, a database

I know there want be any wrong answers.

regards,

J.

---

<div class="post-metadata">

**Author:** ![ace](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/848f3c/32.png) [@ace](https://www.ruby-forum.com/u/ace)\
**Post date:** [October 15, 2007, 11:29am UTC](https://www.ruby-forum.com/t/deploying-in-production-level-ideas-please/117239/2 "2007-10-15T11:29:29Z")

</div>

Hey there,

> 1. Ruby on Rails, with lighttpd/mongrel, a database
> 2. Ruby on Rails, mod\_ruby with Apache2, a database
> 3. Ruby on Rails, FastCGI with Apache2, a database

I used #3 quite a little bit before figuring out that it’s not optimal  
from the following point of view.

Apache has worker threads that handle requests and serve content. When  
some static file is requested (css, js, html, …) the thread is  
created and has a small memory footprint (some 1-5 Mb, which is huge  
compared to some lightweight servers, like nginx). When it’s PHP /  
FastCGI, there has to be more memory allocated (up to 35-50 Mb in my  
experience). As Apache reuses workers, over the time all workers hold  
the maximum memory and, as you can realize, make the server choke  
(constant swapping etc).

What I came up with was a cluster of mongrel workers per application  
(usually 2 is enough if you don’t do anything lengthy during the  
request handling, which is bad by definition, or unless you have an  
application bombarded by requests rapidly). So mongrel + the\_server is  
a great combination. You let the server serve the static content, and  
let mongrel, with almost fixed memory footprint, do the interactive  
job.

I don’t name the\_server as it’s possible to use several solutions in  
this configuration and it’s completely up to you what to go along  
with. I prefer nginx as a front end, which proxies all requests and  
gives PHP to Apache, Rails to Mongrel, while serving static itself.

That’s pretty much all to it.

- A

---

<div class="post-metadata">

**Author:** ![ace](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/848f3c/32.png) [@ace](https://www.ruby-forum.com/u/ace)\
**Post date:** [October 15, 2007, 10:54pm UTC](https://www.ruby-forum.com/t/deploying-in-production-level-ideas-please/117239/3 "2007-10-15T22:54:30Z")

</div>

> I just started using rails.  
> After surfing and reading a lot I need some feedback from you guys.  
> In production level what is the best configuration to use Rails with  
> maximum performance. Correct me if I am wrong please.
> 
> 1. Ruby on Rails, with lighttpd/mongrel, a database
> 2. Ruby on Rails, mod\_ruby with Apache2, a database
> 3. Ruby on Rails, FastCGI with Apache2, a database

1. Nginx and mongrel

Seems to also be a pretty popular choice.

---

<div class="post-metadata">

**Author:** ![ace](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/848f3c/32.png) [@ace](https://www.ruby-forum.com/u/ace)\
**Post date:** [October 16, 2007, 1:03am UTC](https://www.ruby-forum.com/t/deploying-in-production-level-ideas-please/117239/4 "2007-10-16T01:03:49Z")

</div>

Hi ace

Using Apache 2.2x (with mod\_proxy\_balancer) + a pack of mongrels seems  
to be the recommended way…

---

<div class="post-metadata">

**Author:** ![ace](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/848f3c/32.png) [@ace](https://www.ruby-forum.com/u/ace)\
**Post date:** [October 17, 2007, 6:37pm UTC](https://www.ruby-forum.com/t/deploying-in-production-level-ideas-please/117239/5 "2007-10-17T18:37:47Z")

</div>

nginx + mongrel\_cluster is a really good solution if you don’t need  
apache  
OR don’t want to / can’t install Apache 2.2.

Apache 2.2+mongrel\_cluster is great if you need to use Apache, but nginx  
is  
lighter and easier to configure (it does less stuff).

Stay away from mod\_ruby or fastcgi. mod\_ruby will run slow. fastcgi is  
just  
difficult to scale and tends to be a bit flakey. (On a shared host, it  
may  
be your only option though).

Grab the beta of “Deploying Rails Applications”.  
[Pragmatic Bookshelf: By Developers, For Developers](http://www.pragprog.com/titles/fr_deploy) Most of your questions should  
be  
answered there.

---

<div class="post-metadata">

**Author:** ![ace](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/848f3c/32.png) [@ace](https://www.ruby-forum.com/u/ace)\
**Post date:** [October 18, 2007, 9:19am UTC](https://www.ruby-forum.com/t/deploying-in-production-level-ideas-please/117239/6 "2007-10-18T09:19:19Z")

</div>

Hi Brian

Does your book “Rails in Windows” contain a chapter on deployment in  
Windows ?

---

<div class="post-metadata">

**Author:** ![ace](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/848f3c/32.png) [@ace](https://www.ruby-forum.com/u/ace)\
**Post date:** [October 16, 2007, 6:03am UTC](https://www.ruby-forum.com/t/deploying-in-production-level-ideas-please/117239/7 "2007-10-16T06:03:44Z")

</div>

Thanks a lot…

Please let me know others ideas as well!

regards,

J.

---

<div class="post-metadata">

**Author:** ![ace](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/848f3c/32.png) [@ace](https://www.ruby-forum.com/u/ace)\
**Post date:** [October 18, 2007, 3:35pm UTC](https://www.ruby-forum.com/t/deploying-in-production-level-ideas-please/117239/8 "2007-10-18T15:35:08Z")

</div>

No it does not. That’s covered (by be) in “Deploying Rails  
Applications”.  
We wanted to include it in that book too but I had already made the  
committment to Ezra and the Prags for that chapter.

I am working on a new book for O’Reilly that will cover development and  
deployment of Rails apps on a Windows network. It’s geared towards the  
ASP /  
.Net crowd.

---

<div class="post-metadata">

**Author:** ![ace](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/848f3c/32.png) [@ace](https://www.ruby-forum.com/u/ace)\
**Post date:** [October 18, 2007, 5:25pm UTC](https://www.ruby-forum.com/t/deploying-in-production-level-ideas-please/117239/9 "2007-10-18T17:25:21Z")

</div>

Hi Brian

I bought the beta PDF on 8th Oct.  
Just regenerated the PDF five minutes ago and was disappointed not to  
find the chapter written by you ☹

---

<div class="post-metadata">

**Author:** ![ace](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/848f3c/32.png) [@ace](https://www.ruby-forum.com/u/ace)\
**Post date:** [October 18, 2007, 5:30pm UTC](https://www.ruby-forum.com/t/deploying-in-production-level-ideas-please/117239/10 "2007-10-18T17:30:01Z")

</div>

I’ve been assured it’s coming… just don’t know when.

---

<div class="post-metadata">

**Author:** ![ace](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/848f3c/32.png) [@ace](https://www.ruby-forum.com/u/ace)\
**Post date:** [October 19, 2007, 7:26am UTC](https://www.ruby-forum.com/t/deploying-in-production-level-ideas-please/117239/11 "2007-10-19T07:26:49Z")

</div>

There will be a new release of the beta in a week to 10 days that  
will include Brian chapter as well as update the book to cap2 and add  
the nginx/apache chapter.

Cheers-  
-Ezra

---

<div class="post-metadata">

**Author:** ![ace](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/848f3c/32.png) [@ace](https://www.ruby-forum.com/u/ace)\
**Post date:** [October 19, 2007, 2:47pm UTC](https://www.ruby-forum.com/t/deploying-in-production-level-ideas-please/117239/12 "2007-10-19T14:47:44Z")

</div>

Hi Ezra

Great !

BTW, looking at the Balancer-Manager,there are certain info displayed  
for  
each mongrel process such as

Worker URL : [http://127.0.0.1:9001](http://127.0.0.1:9001)  
Route : 1  
Route Redir Factor Set :0  
Status : OK  
Elected : 237  
To :150K

Apart from Worker URL and Status, what does the rest mean ?  
Are there any docs or resources that can explain how to use the  
balancer-manager effectively ?

It would be great to have the answer in your book…  
Have already posted to Apache Forum with no response.
