关于与 Rails 应用程序一起使用的文件服务器的建议
我正在开发一个 Rails 应用程序,它接受文件上传,并且用户可以稍后修改这些文件。例如,他们可以更改文本文件内容或对图像执行基本操作,例如调整大小、裁剪、旋转等。
目前,这些文件存储在 Apache 与 Passenger 运行的同一服务器上,以服务所有应用程序请求。
我需要将用户文件移动到专用服务器以分配我的设置上的负载。目前,我们的用户每周上传大约 10GB 的文件,这个数字并不是很大,但最终会增加。
因此,我将通过不同的选项来实现应用程序服务器和文件服务器之间的通信。我想从一个简单且万无一失的解决方案开始。如果它以后能够在多个文件服务器上很好地扩展,我会非常高兴。
以下是我一直在研究的一些不同选项:
- Amazon S3。我发现我的应用程序实施起来有点困难。它增加了再次“上传”上传文件的复杂性(可能会多次),请注意用户可以使用我的应用程序修改文件和图像。除此之外,这将是一个很好的“设置它并忘记它”的解决方案。
- 某种简单的 RPC 服务器,位于文件服务器上,从应用程序服务器端看时透明地管理文件。我还没有在这里找到任何标准且经过良好测试的工具,所以这在我看来更具理论性。然而,在 GitHub 中构建和使用的 Bert 和 Ernie 看起来很有趣,但刚开始可能太复杂了。
- MogileFS 似乎也很有趣。还没有看到它被使用(但这是我的问题:)。
因此,我正在寻找不同的(可能是基于标准的)方法来实现 Web 应用程序的文件服务器以及它们如何在野外工作。
I'm working on a Rails app that accepts file uploads and where users can modify these files later. For example, they can change the text file contents or perform basic manipulations on images such as resizing, cropping, rotating etc.
At the moment the files are stored on the same server where Apache is running with Passenger to serve all application requests.
I need to move user files to dedicated server to distribute the load on my setup. At the moment our users upload around 10GB of files in a week, which is not huge amount but eventually it adds up.
And so i'm going through a different options on how to implement the communication between application server(s) and a file server. I'd like to start out with a simple and fool-proof solution. If it scales well later across multiple file servers, i'd be more than happy.
Here are some different options i've been investigating:
- Amazon S3. I find it a bit difficult to implement for my application. It adds complexity of "uploading" the uploaded file again (possibly multiple times later), please mind that users can modify files and images with my app. Other than that, it would be nice "set it and forget it" solution.
- Some sort of simple RPC server that lives on file server and transparently manages files when looking from the application server side. I haven't been able to find any standard and well tested tools here yet so this is a bit more theorethical in my mind. However, the Bert and Ernie built and used in GitHub seem interesting but maybe too complex just to start out.
- MogileFS also seems interesting. Haven't seen it in use (but that's my problem :).
So i'm looking for different (and possibly standards-based) approaches how file servers for web applications are implemented and how they have been working in the wild.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
使用S3。它价格便宜,按菜单点菜,如果人们开始下载他们的文件,您的服务器将不必承受压力,因为您的下载页面可以直接指向上传文件的 S3 URL。
“Pedro”在 github.com 上有一个很好的示例应用程序,可以与 S3 配合使用。
我通常非常无能或不幸无法让这些事情发挥作用,但通过 Pedro 的小型 S3 上传应用程序,我取得了成功。祝你好运。
Use S3. It is inexpensive, a-la-carte, and if people start downloading their files, your server won't have to get stressed because your download pages can point directly to the S3 URL of the uploaded file.
"Pedro" has a nice sample application that works with S3 at github.com.
I'm usually terribly incompetent or unlucky at getting these kinds of things working, but with Pedro's little S3 upload application I was successful. Good luck.
您还可以尝试编译 Dropbox 的版本(他们提供源代码)并将其 ln -s 公开给您/system 目录,以便回形针保存到其中。这样您也可以从任何桌面远程访问文件...我还没有这样做,所以我无法证明它是多么容易/困难/有价值,但它在我的 teux deux 列表...:)
you could also try and compile a version of Dropbox (they provide the source) and ln -s that to your public/system directory so paperclip saves to it. this way you can access the files remotely from any desktop as well... I haven't done this yet so i can't attest to how easy/hard/valuable it is but it's on my teux deux list... :)
我认为S3是你最好的选择。有了像 Paperclip 这样的插件,添加到 Rails 应用程序中真的非常容易,而且不必担心扩展,这样就省去了一些麻烦。
I think S3 is your best bet. With a plugin like Paperclip it's really very easy to add to a Rails application, and not having to worry about scaling it will save on headaches.