# Nginx/mongrel with multiple machine deployment

**URL:** <https://www.ruby-forum.com/t/nginx-mongrel-with-multiple-machine-deployment/140905>\
**Category:** Deployment\
**Created:** [June 19, 2008, 6:05pm UTC](https://www.ruby-forum.com/t/nginx-mongrel-with-multiple-machine-deployment/140905 "2008-06-19T18:05:29Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![s0nspark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f475e1/32.png) [@s0nspark](https://www.ruby-forum.com/u/s0nspark)\
**Post date:** [June 19, 2008, 6:05pm UTC](https://www.ruby-forum.com/t/nginx-mongrel-with-multiple-machine-deployment/140905/1 "2008-06-19T18:05:29Z")

</div>

I am in the process of migrating an app that currently resides on a  
single hardware server (running pound, nginx as an asset host,  
memcached, mongrel and mysql) to a new group of xen virtual machines: an  
appserver running the mongrels, a webserver running nginx (which will be  
handling the proxying now as well) and memcached, and a database server  
running mysql.

One of the apps I am moving handles file uploads and I realize that I  
now have to account for the fact that uploaded content should reside on  
the webserver rather than the appserver since I have a rewrite rule in  
my nginx config to check for static content before proxying to rails.  
Also, maybe I’m thinking myself in a knot, my current rails code does  
some post-processing of the upload but I am not clear which server  
(rails or nginx) handles the upload and when… Could someone shed some  
light on this for me?

My first thought regarding the uploaded file’s final destination is to  
export the public directory via NFS on the webserver and mount it on the  
appserver but I am leery of using NFS, partially because I haven’t ever  
and partially because of its reputation for performance issues.

Is there a recommended way of handling this?

---

<div class="post-metadata">

**Author:** ![s0nspark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f475e1/32.png) [@s0nspark](https://www.ruby-forum.com/u/s0nspark)\
**Post date:** [June 19, 2008, 6:41pm UTC](https://www.ruby-forum.com/t/nginx-mongrel-with-multiple-machine-deployment/140905/2 "2008-06-19T18:41:25Z")

</div>

I have a similar setup and what I did was open an Amazon S3 account and  
use  
attachment\_fu to push the uploads to it. So my servers can access it all  
from a single point now.

Raul

----- Original Message -----  
From: “Tim F.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Sent: Thursday, June 19, 2008 9:05 AM  
Subject: [Rails-deploy] nginx/mongrel with multiple machine deployment

---

<div class="post-metadata">

**Author:** ![s0nspark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f475e1/32.png) [@s0nspark](https://www.ruby-forum.com/u/s0nspark)\
**Post date:** [June 19, 2008, 7:17pm UTC](https://www.ruby-forum.com/t/nginx-mongrel-with-multiple-machine-deployment/140905/3 "2008-06-19T19:17:02Z")

</div>

Raul wrote:

> I have a similar setup and what I did was open an Amazon S3 account and  
> use  
> attachment\_fu to push the uploads to it. So my servers can access it all  
> from a single point now.

Thanks Raul - not a bad idea, but unfortunately not an option with this  
app, due to some other restrictions that limit me to a local filesystem.

Any other ideas?

---

<div class="post-metadata">

**Author:** ![s0nspark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f475e1/32.png) [@s0nspark](https://www.ruby-forum.com/u/s0nspark)\
**Post date:** [June 19, 2008, 7:40pm UTC](https://www.ruby-forum.com/t/nginx-mongrel-with-multiple-machine-deployment/140905/4 "2008-06-19T19:40:33Z")

</div>

Ugh, I actually ran with NFS for a couple of months but I was losing  
sleep  
at night wondering if it would keep on chugging along.

The other thing you can do is just set up one more reliable webserver  
(better yet, two in a cluster, load balanced) as your asset server,  
deploy a  
copy of your public folder there and make all your uploads write to that  
server.

I also toyed with the idea of file replication amongst all my web  
servers  
but having never done it I was reluctant to give it a go.

Hopefully one or some combo of these will give you some inspiration to  
do  
what I haven’t. 🙂

Raul

----- Original Message -----  
From: “Tim F.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Sent: Thursday, June 19, 2008 10:17 AM  
Subject: [Rails-deploy] Re: nginx/mongrel with multiple machine  
deployment

---

<div class="post-metadata">

**Author:** ![s0nspark](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f475e1/32.png) [@s0nspark](https://www.ruby-forum.com/u/s0nspark)\
**Post date:** [June 20, 2008, 3:33am UTC](https://www.ruby-forum.com/t/nginx-mongrel-with-multiple-machine-deployment/140905/5 "2008-06-20T03:33:43Z")

</div>

On Thu, 2008-06-19 at 10:39 -0700, Raul wrote:

> Ugh, I actually ran with NFS for a couple of months but I was losing sleep  
> at night wondering if it would keep on chugging along.
> 
> The other thing you can do is just set up one more reliable webserver  
> (better yet, two in a cluster, load balanced) as your asset server, deploy a  
> copy of your public folder there and make all your uploads write to that  
> server.
> 
> I also toyed with the idea of file replication amongst all my web servers  
> but having never done it I was reluctant to give it a go.

I’ve done this with rsync and it’s worked pretty well. At first go you  
can set it up with rsync over ssh, and then when you have time go back  
and just open port 873 and run rsync unencrypted and save yourself some  
CPU time.

Yours,

Tom
