How to get Rails 4 ActionController::Live streaming working with Thin and Ruby 2? And how do Thin and Puma scale with live streaming?

为君一笑 提交于 2019-11-29 14:33:58

问题


I get it working with Puma, but with Thin I don't get any stream output and I have to kill the server to stop it. I'm testing using tenderlove's initial example outputing the current time:

http://tenderlovemaking.com/2012/07/30/is-it-live.html

A more general question to me is, is this type of streaming practical in an app with any significant traffic? I imagine there can be easily hunderts if not thousands of users connected to a stream at once in such app. How would Puma scale here? I read that Puma uses 1 thread per connection. Is that efficient? And what about Thin? Will all connections be in the same thread? Will that be more efficient?

Another issue I have is that even with Puma I only get one connection working locally. When I curl from a second terminal I don't get any output there... Anybody know why?


回答1:


If you change your development.rb inside environments:

/config/environments/development.rb

config.cache_classes = true

config.eager_load = true

You will be able to get more than one connection with puma localy! The downside is that you have to restart everytime you want to see any changes you've made.



来源:https://stackoverflow.com/questions/15441302/how-to-get-rails-4-actioncontrollerlive-streaming-working-with-thin-and-ruby-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!