i am working on a website which deploy on web farms to serve high traffic. where should i store user uploaded files? is it wise to store uploaded files in the file system of the same website and synchronize these files in all web servers(web farm)? or should i use another server to store all uploaded files in this server to store files in a central location? if separate file server will be a better choice, than how can i pass files from web server to that file server efficiently? or should i upload files directly to that file server?
views:
160answers:
3For security reasons you want to serve the files from a different sub-domain anyways. This is easier by dedicating one server for these files, if the traffic for these files warrants it, but that also creates a single point of failure and bottleneck which you probably want to avoid.
You can have all web servers serve the files from a central file server or local cached copies. This depends a lot on if the files ever change.
Have you considered using Amazon S3 to store and serve user-uploaded files?
Otherwise, a central file server in your data center makes sense. You could mount the storage locally on each of your web servers using NFS or similar.
However you choose to store these files, you should always serve user-provided files from a different domain to avoid cross-domain exploits.
You asked about how Facebook stores photos. You might want to read the following article:
Needle in a haystack: efficient storage of billions of photos