[OT] sync of static resources in shared-nothing architecture

If we have the setup 1 balances N web-servers 1 database server, and
users my upload resources like an image, how do you sync the public
directories?

– fxn

From my recent blog post on the topic, http://www.bencurtis.com/
archives/2006/11/how-to-handle-uploaded-files-with-rails/, use rsync:

rsync -cure ssh /source/path/ destination_server.com:/destination/path/

Assuming you can log in to the other box via SSH keys, this rsync
command can be put in a cron job or triggered by a directory watcher
to keep one or more other hosts in sync with the master upload
directory.


Building an e-commerce site with Rails?
http://www.agilewebdevelopment.com/rails-ecommerce

If we have the setup 1 balances N web-servers 1 database server, and
users my upload resources like an image, how do you sync the public
directories?

While our users don’t upload content, our content folks do. Our setup
looks like this:

N web servers
1 content admin server (same as web, just dedicated to our staff)
1 master media server
4 media slaves

When staff upload an image/video/pdf/flash/etc via the content admin
server it then re-posts it to the master media server which stores on
disk, then “tickles” (via curl) each of the slaves to request that url.
The slaves are configured with an error handler such that if they don’t
have the the resource they fetch it from the master and then redirect to
itself.

This way 99% of the time images are immediately spread to all the
slaves,
but on the off chance they aren’t, the slaves can still fetch it when
someone requests it.

We’ve found that curl is fast enough that the fetch-then-redirect-to-m
yself isn’t noticable…

-philip

You might also consider putting the shared static resources on an
central file store, and mounting that volume by NFS on all your web
servers. With Lingr (http://www.lingr.com), for example, images that
users upload go onto an NFS-mounted volume that physically lives on the
database server.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs