【问题标题】:Does HTTP streaming in Rails 3.1 work with Thin?Rails 3.1 中的 HTTP 流式传输是否适用于 Thin?
【发布时间】:2011-05-24 05:46:32
【问题描述】:

Rails 3.1 支持 HTTP 流式传输,但仅适用于兼容的 Web 服务器。宣布 3.1 候选版本的博客文章提到了 Unicorn: http://weblog.rubyonrails.org/2011/5/22/rails-3-1-release-candidate

API 文档还提到了 Unicorn,并为乘客提供了一个存根: https://github.com/rails/rails/blob/master/actionpack/lib/action_controller/metal/streaming.rb

有谁知道是否支持 Thin,如果支持,我在哪里可以找到配置信息?

【问题讨论】:

  • 我能够让 Thin “流式传输”数据。看看这个question on pushing asynchronous data to the body的答案。作为警告,这种方法更像是一种 hack,从技术上讲,它不是使用 content-type: chunked 的 html5 流式传输,但我已经让它在我自己的机器上运行。

标签: ruby-on-rails thin unicorn ruby-on-rails-3.1


【解决方案1】:

在 0.5.4 版本的发行说明中:

    == 0.5.4 Flying Mustard release
     * Don't read the full body, use direct streaming when sending response.
       See: Response#each
       As a result, the Content-Length can not be calculated anymore.
       You have to do set this in your adapter. All frameworks do it anyway.
       It improve memory usage and boost speed for low concurrency.
       Thanks to Kent Sibilev and Ezra for their help on that one.

但是,当我运行两个瘦实例(在不同的端口上,一个设置为资产主机)时,布局中的 CSS 和 JS 在控制器操作中的 sleep 调用完成执行之前没有加载。这是在生产模式下完成的。

我不能 100% 确定它的机制,也许需要设置瘦机架适配器以允许流式传输。

【讨论】:

  • 我不确定睡觉是否可以作为瘦身的测试,因为它会阻塞反应器并阻止瘦身在您睡觉时提供其他任何东西。不过我可能是错的。
猜你喜欢
  • 2011-09-01
  • 1970-01-01
  • 2011-11-06
  • 2011-11-22
  • 2020-01-10
  • 1970-01-01
  • 1970-01-01
  • 2012-01-05
  • 1970-01-01
相关资源
最近更新 更多