关于与 Rails 应用程序一起使用的文件服务器的建议

发布于 2024-08-21 18:29:43 字数 723 浏览 4 评论 0原文

我正在开发一个 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

东京女 2024-08-28 18:29:43

使用S3。它价格便宜,按菜单点菜,如果人们开始下载他们的文件,您的服务器将不必承受压力,因为您的下载页面可以直接指向上传文件的 S3 URL。

“Pedro”在 github.com 上有一个很好的示例应用程序,可以与 S3 配合使用。

  1. 克隆应用程序 ( git clone git://github.com/pedro/paperclip-on-heroku.git )
  2. 确保您已安装 right_aws gem。
  3. 将您的 Amazon S3 凭证(API 和密钥)放入 config/s3.yml
  4. 安装 Firefox S3 插件 (http:// www.s3fox.net/)
  5. 进入 Firefox S3 插件并输入您的 api &秘密。
  6. 使用 S3 插件创建一个具有唯一名称的存储桶,可能是“your-paperclip-demo”。
  7. 编辑 app/models/user.rb,并将您的存储桶名称放在倒数第二行 (:bucket => 'your-paperclip-demo')。
  8. 在本地启动服务器并将一些文件上传到本地应用程序。您将从 S3 插件中看到该文件已上传到新存储桶中的 Amazon 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.

  1. Clone the application ( git clone git://github.com/pedro/paperclip-on-heroku.git )
  2. Make sure that you have the right_aws gem installed.
  3. Put your Amazon S3 credentials (API & secret) into config/s3.yml
  4. Install the Firefox S3 plugin (http://www.s3fox.net/)
  5. Go into Firefox S3 plugin and put in your api & secret.
  6. Use the S3 plugin to create a bucket with a unique name, perhaps 'your-paperclip-demo'.
  7. Edit app/models/user.rb, and put your bucket name on the second last line (:bucket => 'your-paperclip-demo').
  8. Fire up your server locally and upload some files to your local app. You'll see from the S3 plugin that the file was uploaded to Amazon S3 in your new bucket.

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.

国际总奸 2024-08-28 18:29:43

您还可以尝试编译 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... :)

美人骨 2024-08-28 18:29:43

我认为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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文