带有 Socket.io 模块的 Node.js 与 XMPP - 优点和缺点
我有一个带有 Socket.io 聊天应用程序的 Node.js 和一个 XMPP Openfire 聊天系统。我期待着用 Node.js 和 Socket.io 替换 XMPP。然而,有传言称,带有 Socket.io 的 Node.js 会遇到问题,如果服务器崩溃并重新上线,就会出现瓶颈综合症,或者可能无法重新连接 10,000 个在线用户。这是真的吗?
另一个问题。在什么情况下 XMPP 比 Socket.io 更合适,反之亦然?
I have a Node.js with Socket.io chat application and an XMPP Openfire chat system. I'm looking forward to replacing XMPP with Node.js and Socket.io. However, there is talk that, Node.js with Socket.io would have a problem, if the server crashes and goes back online it would have a bottleneck syndrome or maybe impossible to reconnect 10,000 of it's online users. Is that true?
Another question. In what case would XMPP be more appropriate than Socket.io and vice versa?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
XMPP 是面向消息的中间件的开放标准通信协议(维基百科)。
Node.js 是一个基于 JavaScript 的开发工具,用于创建网络服务。
这两件事确实没有可比性。如果您使用 socket.io 构建了一个聊天应用程序,它可能会遇到瓶颈综合症,但这在很大程度上取决于您的应用程序代码。
一般来说,如果您想要超越简单的基于浏览器的聊天,我会认真考虑 XMPP(又名 Jabber),因为 XMPP 客户端随时可用于所有操作系统。
XMPP is an open-standard communications protocol for message-oriented middleware (Wikipedia).
Node.js is a JavaScript-based developer tool for creating network services.
Those two things don't really compare. If you have built a chat application with socket.io, it's possible that it'll suffer from bottleneck syndrome, but it depends a lot on your application code.
In general, if you want to go beyond simple browser-based chat, I'd seriously consider XMPP (aka. Jabber), since there XMPP clients readily available for all OS'es.
我认为 Node.js 的优点在于它是用一种常见的理解语言(Javascript)编写的,而不是用 XMPP 服务器编写的,而 XMPP 服务器的常见语言是用 erlang/Java 编写的,而后者并没有被广泛理解。
如果您想完全控制服务器行为并编写巧妙的模块,那么我怀疑节点将是您的最佳解决方案。
Node.js 可能失败的地方是,如果您需要扩展到一台服务器之外,则必须将其设计到您的节点应用程序中。我相信 eJabberd 和 Openfire 都支持开箱即用的集群,因此您所需要做的就是使另一台服务器联机,配置两者以相互通信,然后就可以开始使用了。
我对您的总体建议是,如果当前的 XMPP 系统适合您,那么我会坚持使用它。
I think that the pros of Node.js are that it's written in a commonly understood language (Javascript) rather than XMPP servers which the common ones are written in erlang/Java which aren't so widely understood.
If you want to have full control over the server behaviour and write clever modules then I suspect that node will be the best solution for you.
The place that Node.js could fall down is that if you ever need to scale beyond one server you're going to have to engineer this into your node app. I believe that eJabberd and Openfire both support clustering out of the box so all you'd need to do is bring another server online, configure the two to talk to each other and off you go.
My overall advice to you would be that if the current XMPP system is working fine for you then I'd just stick with it.
正如mikl所说,XMPP是一个协议,而不是一个应用程序框架。
您可以在 NodeJS 之上构建 XMPP 应用程序,就像在 NodeJS 之上构建 SocketIO 应用程序一样。不同之处在于,与您自己构建的某些解决方案相比,OpenFire 和 ejabberd 已经存在并经过了一段时间的测试。这并不意味着您应该这样做,但它确实意味着您应该有一个良好的商业案例来这样做。
如果您正确设置了基础架构,则几乎可以在任何框架中执行此操作。为了减少峰值期间的延迟,您应该对请求进行负载平衡,这也可能是任何系统所需要的。
As mikl said, XMPP is a protocol and not an application framework.
You can build XMPP applications on top of NodeJS in the same way that you can build SocketIO applications on top of NodeJS. The difference is that OpenFire and ejabberd have been around and tested for some time versus some solution you'd build on your own. That doesn't mean you should do it, but it does mean you should have a good business case for doing so.
If you're setting your infrastructure up properly, you can do this in pretty much any framework. To mitigate your latency during spikes you should load balance your requests which will also likely be required with any system.
您还可以检查旨在与 Node.js 配合使用的 xmppjs 库。
http://xmppjs.prosody.im/
You can also check the xmppjs library designed to work with node.js.
http://xmppjs.prosody.im/