How to handle uploaded files in HA cluster?

Hi, i am planning to build HA cluster for rails applications, using guideline How to build a state-of-the-art rails cluster from Tim Loosen.

Database replication should be easy with MySQL, I am currently using master-slave replication for backups, so configuring master-master wouldn't be a big deal (as I hope). But I am wondering how to handle file uploads? First way which come into me mind was cross-exporting upload directories via NFS and slightly modifying file_column plugin. Another way is to store files in database, so MySQL replication will be used and than perform some way of caching (reading big files from database again and again doesn't look like a good idea to me).

Any ideas how to solve this?

Regards

Láďa

Use Amazon S3.

Then you are clustering DB but don't need to cluster/replicate FS.

It's not a good idea to keep files in the DB as a rule. Of course, you _can_, but you'd have to really think through it.

-Danimal

Never *ever* store images in the database especially if you are doing replication or master master, sotring images in the db is very inefficient and will completely hose replication on the regular.

  NFS can work but has locking issues and is not POSIX compliant and is also fairly slow. If you have a SAN then you can use GFS from the red hat cluster suite to get a posix compliant clustered filesystem.

Cheers- - Ezra Zygmuntowicz -- Founder & Software Architect -- ezra@engineyard.com -- EngineYard.com

Thanks for replication explanation. GFS looks like a good way, but I think that it has two drawbacks: - introducing another single-point-of-failure - SAN requirement

I would like to make this happen with two servers only + loadbalancer and pretty low-cost - applications are not heavy loaded, but failover would be a great feature. Is there eg. some way how to replicate directory via rsync/SSH/ whatever through daemon? There will be only a minimum file-upload operations, so having not-so-realtime replication of files would be sufficient.

Cheers

Láďa

How about using something like:

http://www.danga.com/mogilefs/