问题描述
我很好奇我可以同时使用socket.io和Cluster。
I'm curious that I can use both socket.io and Cluster.
我知道集群使用多核在具有多个工作程序的node.js上工作。
I know that cluster uses multi-core to work on node.js with multiple workers.
这意味着,如果我将cluster用于socket.io,则两个连接了
That means if I use cluster for socket.io, two users with connected on
两个不同套接字的用户.io可能会导致它们无法相互通信的问题?
two different socket.io might cause problem that they cannot communicate each other?
因此,宁愿不使用socket.io上的集群也是一个答案?
So rather not using cluster on socket.io would be an answer?
推荐答案
结帐dshaw关于扩展Socket.IO的讨论和示例应用程序:
Checkout dshaw's talk and sample app regarding scaling Socket.IO: https://github.com/dshaw/talks/tree/master/2011-10-jsclub/sample-app
Also this stackoverflow question might help:How to reuse redis connection in socket.io?
基本上将Redis用作具有一个或多个c的pub-sub交换消息的渠道。
Basically use Redis as a pub-sub with one or multiple channels on which messages are exchanged.
这篇关于在集群中使用socket.io吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!