简体   繁体   English

如何使用单个流提供多个连接?

[英]How to serve multiple connections with a single stream?

I'm just at the high-level of forming a concept here, so I'm really just looking for thoughts/ideas/suggestions about how this might be done -- if there's already something that does this, if I need to roll my own, or if maybe there's a couple separate projects that could be cobbled together to achieve this. 我只是在这里形成一个概念的高级别,所以我真的只是在寻找关于如何做到这一点的想法/想法/建议 - 如果我已经有了这样的事情,如果我需要滚动我的拥有,或者如果可能有几个单独的项目可以拼凑在一起实现这一目标。 Any and all input is appreciated :) 任何和所有输入赞赏:)

What I'd like to be able to do is have a "stream" (not sure what else to call it) broadcast ? 我希望能做的是有一个 “流”(不知道还有什么叫它) 广播 of data that will be served over an HTTP connection. 将通过HTTP连接提供的数据。 This stream will serve events/updates/other data to clients that have subscribed to it (doesn't matter really what the data is, just that the client has subscribed in some fashion). 此流将向订阅它的客户端提供事件/更新/其他数据(实际上数据无关紧要,只是客户端以某种方式订阅)。 This is nothing even remotely new, but what I'm having trouble tracking down is a way for multiple users/clients/connections to basically share the same stream/connection. 这甚至都不是什么新东西,但是我在跟踪时遇到的问题是多个用户/客户端/连接基本上共享相同的流/连接的方式。 In other words, I'm looking for a way for a web server to basically send data once and have all subscribed clients receive it. 换句话说,我正在寻找一种方法让Web服务器基本上发送一次数据并让所有订阅的客户端接收它。 This way, for high-traffic applications, the web server doesn't have to send data explicitly to each and every listening connection. 这样,对于高流量应用程序,Web服务器不必显式地向每个侦听连接发送数据。
I really hope that made sense. 我真的希望这是有道理的。

  • Are there webservers/webserver-plugins that can already do this? 是否有可以执行此操作的webservers / webserver-plugins?
  • Would it be possible/feasible to adapt some form of video streaming library to achieve this? 是否有可能/可行地调整某种形式的视频流库来实现这一目标?
  • Is this something I'll probably have to manage on my own (code that tracks subscribed connections, receives new data from some other service, and transparently replicates said data to each individual connection)? 这是我可能需要自己管理的东西(跟踪订阅连接的代码,从其他服务接收新数据,并透明地将所述数据复制到每个单独的连接)?
  • Any other ideas, thoughts, concerns, caveats, etc? 任何其他想法,想法,顾虑,警告等?

Take a look at http://wiki.nginx.org/HttpPushStreamModule - it seems to answer what you're after in terms of existing functionality to track subscribed connections and relaying data to each client. 看看http://wiki.nginx.org/HttpPushStreamModule - 它似乎回答了你现有的功能,以跟踪订阅的连接和向每个客户端中继数据。 It looks like it would take a bit to set up your data source as a channel, but beyond that it handles the rest. 看起来将数据源设置为通道需要一些时间,但除此之外,它还会处理其余的数据源。

I haven't used that module before, but have used Nginx itself -- it's quite nice and handles concurrent connections well. 我之前没有使用过那个模块,但是已经使用过Nginx - 它非常好用并且可以很好地处理并发连接。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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