Heroku上传大文件到s3时超时
我的基于 RefineryCMS 1.0.8 的应用程序出现问题 部署在heroku上。
Heroku 的请求超时为 30 秒。上传文件时> 4MO 通过 RefineryCMS 管理,有时需要超过 执行请求需要 30 秒(主要是因为需要时间 将文件上传到 s3)。
在这种情况下,测功机将被“冻结”并且 大约 30 分钟没有响应(在此期间的每个请求都结束 由 H12 错误请求超时引起)。此行为正是 此讨论
从此其他讨论 和 heroku 文档 :“如果您是,直接上传到 S3 是首选方法 处理大于 4MB 的文件上传。这个想法是跳过跳跃 到您的 dyno,直接从最终用户浏览器建立连接 到S3。”
直接上传到S3应该是解决方案,但看起来很困难 让我可以使用 RefineryCMS / Dragonfly / Fog 正确实施它。我不确定是否可以在不对这些工具进行重大修改的情况下实现这一点,我想知道是否有替代方案。
感谢您的帮助
I got a problem with my application based on RefineryCMS 1.0.8
deployed on heroku.
Heroku have a request timeout of 30 seconds. When uploading a file >
4MO through the RefineryCMS admin, it will sometimes take more than
30 seconds to perform the request (mostly because of the time needed to
upload the file to s3).
In this case, the dyno will be "frozen" and
unresponsive for around 30 minutes (every request during this time end
up by a H12 Error request timeout). This behaviour is exactly what describe christos in the last message in this discussion
From this other discussion
and the heroku documentation
: "Direct Upload to S3 is the preferred approach if you’re
working with file uploads bigger than 4MB. The idea is to skip the hop
to your dyno, making a connection from the end user browser directly
to S3."
The direct upload to S3 should be the solution but it looks difficult
for me to implement it properly with RefineryCMS / Dragonfly / Fog. I'm not sure if it's possible without big modification in theses tools and I'm wondering if there is an alternative.
Thanks for your help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
并不真地。 Heroku 超时是您需要解决的一成不变的问题。直接上传到 S3 是唯一的选择,需要某种上传后处理。
有一些解决方案,例如 CarrierWaveDirect,但我不知道这使用起来有多容易炼油厂。
Not really. The Heroku timeout is a set in stone thing that you need to work around. Direct upload to S3 is the only option, with some sort of post-upload processing required.
There are solutions out there such as CarrierWaveDirect, but I don't know how easy this would be to use with Refinery.
您可以尝试将独角兽添加到您的应用程序中。
config/unicorn.rb
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)
超时 180 # << Unicorn Timeout 将允许更长的上传时间。
preload_app true
before_fork do |服务器,工作人员|
https://devcenter.heroku.com/articles/rails-unicorn
You could try to add unicorn to your application.
config/unicorn.rb
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)
timeout 180 # << Unicorn Timeout will allow a longer upload time.
preload_app true
before_fork do |server, worker|
https://devcenter.heroku.com/articles/rails-unicorn