如何让 Rails 4 ActionController::Live 流与 Thin 和 Ruby 2 一起工作?Thin 和 Puma 如何通过直播进行扩展? [英] How to get Rails 4 ActionController::Live streaming working with Thin and Ruby 2? And how do Thin and Puma scale with live streaming?

查看:72
本文介绍了如何让 Rails 4 ActionController::Live 流与 Thin 和 Ruby 2 一起工作?Thin 和 Puma 如何通过直播进行扩展?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我让它与 Puma 一起工作,但使用 Thin 我没有得到任何流输出,我必须杀死服务器才能停止它.我正在使用tenderlove输出当前时间的初始示例进行测试:

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

对我来说,一个更普遍的问题是,这种类型的流媒体在流量很大的应用中是否实用?我想如果不是成千上万的用户在这样的应用程序中同时连接到一个流,那么很容易就会有成百上千的用户.彪马将如何扩大规模?我读到 Puma 每个连接使用 1 个线程.这样有效率吗?薄呢?所有连接都在同一个线程中吗?这样会更有效率吗?

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?

我遇到的另一个问题是,即使使用 Puma,我也只能在本地获得一个连接.当我从第二个终端卷曲时,那里没有任何输出......有人知道为什么吗?

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?

推荐答案

如果你改变你的 development.rb 内部环境:

If you change your development.rb inside environments:

/config/environments/development.rb

config.cache_classes = true

config.eager_load = true

您将能够与 puma localy 建立不止一个联系!缺点是每次要查看所做的任何更改时都必须重新启动.

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.

这篇关于如何让 Rails 4 ActionController::Live 流与 Thin 和 Ruby 2 一起工作?Thin 和 Puma 如何通过直播进行扩展?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆