Rails 3.1 supports HTTP streaming, but only with compatible web servers. The blog post announcing the 3.1 release candidate mentions Unicorn: http://weblog.rubyonrails.org/2011/5/22/rails-3-1-release-candidate
And the API docs also me开发者_运维问答ntion Unicorn, and have a stub for Passenger: https://github.com/rails/rails/blob/master/actionpack/lib/action_controller/metal/streaming.rb
Does anyone know if Thin is supported, and if so, where I can find configuration info?
In the release notes for the 0.5.4 release:
== 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.
However when I ran two thin instances (on different ports, one set as the asset host), the CSS and JS in the layout were not loaded before the sleep
call in the controller action had finished executing. This was done in production mode.
I'm not 100% sure of the mechanics of it, perhaps the Thin rack-adapter needs to be setup to allow streaming.
精彩评论