Nginx/mongrel with multiple machine deployment

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?

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.” [email protected]
To: [email protected]
Sent: Thursday, June 19, 2008 9:05 AM
Subject: [Rails-deploy] nginx/mongrel with multiple machine deployment

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?

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. :slight_smile:

Raul

----- Original Message -----
From: “Tim F.” [email protected]
To: [email protected]
Sent: Thursday, June 19, 2008 10:17 AM
Subject: [Rails-deploy] Re: nginx/mongrel with multiple machine
deployment

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