没有共享内存存储的负载平衡 socket.io 服务器的解决方法
我有一个 node.js / socket.io 应用程序需要在负载平衡服务器上运行。服务器没有启用粘性会话,因此我无法使用 Redis 之类的东西为 socket.io 创建共享内存存储。
socket.io 网站建议按照所附插图进行操作(取自 此处)
我的问题是你如何实际实现这个?
从逻辑上讲,这是有道理的 - 在所有服务器之间建立连接,以便它们可以在彼此之间传递任何消息。是否已经有一个节点模块可以做到这一点,或者我需要提出自己的逻辑?这是否需要在每个服务器之间创建额外的套接字连接?因此知道每个服务器的内部 IP 以便从每个其他服务器连接到它们?
我知道这不是推荐的工作流程,而且绝对不理想。我觉得这个解决方案可能相当复杂。但如果有人提出实现这一目标的最佳方法的建议,那将会有所帮助。谢谢!
I have a node.js / socket.io app that needs to run on a load balanced server. The server does not have sticky sessions enabled, so I cannot use something such as Redis to create a shared memory store for socket.io.
The socket.io website suggests doing something as per the attached illustration (taken from here)
My question is how could you go about actually implementing this?
Logically it makes sense - set up a connection between all the servers so they can pass any messages between themselves. Is there a node module already that can do this, or do I need to come up with my own logic? Would this require creating an additional socket connection between every server? And therefore knowing the internal IP of each server in order to connect to them all from every other server?
I know this isn't a recommended workflow and definitely isn't ideal. I feel like the solution may prove fairly overcomplicated. But if anyone has a suggestion of the best way to achieve this, that would be helpful. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这不是您要问的,但如果您禁用 HTTP 长轮询传输,则不需要粘性会话,根据您的链接:
这就是 Socket.IO 对于长轮询的说法,因此请记住这一点:
那么您将能够使用 Redis适配器在节点之间传递事件。
This is not what you are asking but if you disable HTTP long-polling transport you don't need sticky sessions, per your link:
This is what Socket.IO has to say about long polling, so keep this in mind:
Then you will be able to use the redis adapter to pass events between nodes.