在高流量网络场场景网站中如何以及在何处存储用户上传的文件?
我正在开发一个部署在网络农场上以服务高流量的网站。 我应该在哪里存储用户上传的文件?将上传的文件存储在同一网站的文件系统中并在所有网络服务器(网络场)中同步这些文件是否明智?或者我应该使用另一台服务器将所有上传的文件存储在该服务器中以将文件存储在中央位置? 如果单独的文件服务器是更好的选择,那么我如何有效地将文件从 Web 服务器传递到该文件服务器? 或者我应该将文件直接上传到该文件服务器?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
出于安全原因,您无论如何都希望从不同的子域提供文件。如果这些文件的流量允许的话,通过为这些文件专用一台服务器会更容易,但这也会造成您可能希望避免的单点故障和瓶颈。
您可以让所有 Web 服务器提供来自中央文件服务器或本地缓存副本的文件。这在很大程度上取决于文件是否发生变化。
For 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.
您是否考虑过使用 Amazon S3 来存储和提供用户上传的文件?
否则,数据中心的中央文件服务器是有意义的。您可以使用 NFS 或类似方式在每个 Web 服务器上本地安装存储。
无论您选择如何存储这些文件,您都应该始终从不同的域提供用户提供的文件,以避免跨域攻击。
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.
您询问 Facebook 如何存储照片。您可能想阅读以下文章:
大海捞针:高效存储数十亿张照片
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