22

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?

cnotethegr8
  • 6,160
  • 7
  • 58
  • 91
user739217
  • 221
  • 1
  • 2
  • 4

4 Answers4

13

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.

mikl
  • 21,944
  • 17
  • 64
  • 88
  • Hey Mikl thanks for the input. what make you think nodejs is possible to suffer from bottleneck syndrome? – user739217 May 05 '11 at 15:20
  • I don't think Node.js in itself has inherent bottlenecks, but if you build a chat server on top of Node.js (Node itself is just a toolkit for building network services), it would have to be very carefully engineered to be able to handle 10.000 users reconnecting at once. The main problem will be to get all the data required to validate users and send them whatever chat messages they may have missed. That’s several database queries multiplied by 10.000. Few systems can handle that within a few seconds. – mikl May 05 '11 at 17:34
  • Is scalability an issue with node.js when building a xmmp framework on top of it – Hanu Dec 17 '13 at 06:43
11

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.

James C
  • 13,501
  • 1
  • 32
  • 42
  • Thanks for the input James. So if nodejs is hosted in cloud server, that would elimiate it's disavantage over Openfire or eJabberd clustering support. Our Openfire XMPP server is having memory leak problem, just so you know. – user739217 May 05 '11 at 15:28
  • but you still have to write and maintain the node.js solution – James C May 05 '11 at 15:54
  • Socket.io now supports clustering http://socket.io/#announcement, alternatively use http://pubsub.io, a stand alone clustered message hub written in nodejs – ianj Jul 02 '11 at 08:56
  • 4
    Hilarity bonus points for implying that Java is an obscure language! – clacke Sep 29 '11 at 05:25
4

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.

Nick Campbell
  • 527
  • 2
  • 5
3

You can also check the xmppjs library designed to work with node.js. http://xmppjs.prosody.im/

user847585
  • 31
  • 1