简体   繁体   中英

Does HTTP streaming in Rails 3.1 work with Thin?

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 mention 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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM