top | item 1820779

Is node.js best for Comet?

26 points| olegp | 15 years ago |amix.dk | reply

26 comments

order
[+] ericflo|15 years ago|reply
"best" is a very subjective word.

If we're talking about performance, I'd venture to guess it goes something like this:

C > Java > Scala/Clojure> node.js > Python > Ruby

But then there's all of the other tradeoffs, like how error-prone each environment is or how long it will take to code and debug in each language.

Note that Urban Airship recently did some research and found that Java with direct NIO code worked the best for them, not Netty: http://blog.urbanairship.com/blog/2010/08/24/c500k-in-action...

[+] amix|15 years ago|reply
I think the ultimate perfomance is found in pure java.nio/C/C++ solutions, but I think having a bit slower perfomance and higher abstraction is better since it makes it much easier to maintain and debug the system. My general impression of java.nio is that it's very low-level and a generally hard to code against and it's the main reason why we didn't choose it.

This said, I think node.js offers great usability while perfomance is pretty good. So if I was developing a new comet solution I would give node a go - you can always rewrite to something more low level once you begin to hit limits. IMO going after java.nio directly is a premature optimization and most projects won't hit limits with node.js.

[+] pmjordan|15 years ago|reply
It also heavily depends on what kind of state you're maintaining, whether any of it needs to be persisted or shared across connections, and how much CPU load the processing outside of pure connection handling will produce. Having a suitable scalability mechanism may be worth more than reduction of per-connection-event CPU cycles. (scaling beyond more than one core, scaling beyond more than one server)
[+] cmelbye|15 years ago|reply
Why is Ruby last? EventMachine should work pretty well for most purposes I think.
[+] davidw|15 years ago|reply
Erlang deserves a mention too, although ultimately I'm a bit pessimistic about their chances to break out of the small niche language space.
[+] silentbicycle|15 years ago|reply
Me too. Awesome language/platform, but probably a bit too weird for where the industry at large is at these days, unfortunately.

Anybody else coming to ErlangCamp in Chicago this weekend, BTW?

[+] amix|15 years ago|reply
I think Erlang would be a great fit for comet, especially since it's already proven itself for Facebook chat. Erlang as a language is quite alien to me tho' and I generally prefer Java over it, but I am pretty sure that a Erlang solution would scale very well.
[+] ericflo|15 years ago|reply
Yeah Erlang is great for a lot of things, including Comet.
[+] jacksonh|15 years ago|reply
I've been working on my own framework called Manos de Mono. It runs on top of Mono and is styled after node.js. I am hoping that it will be really good for these scenarios and the Mono runtime will address some of these concerns.

All that being said: node.js is impressively good. Its a beautiful piece of software.

[+] flipp|15 years ago|reply
Socket.io + node.js makes it super easy. It abstracts away all of the transport protocols so you can just focus on writing your application.
[+] equark|15 years ago|reply
Same goes for TornadoSocketIO though, so this isn't unique to node.js.
[+] silentbicycle|15 years ago|reply
This would really be best handled as two separate questions -- "is a fully asynchronous approach best for Comet" and "is the node.js implementation best for Comet" are probably very different discussions. And again, "best" could mean either performance/scalability, usability, or some combination thereof.
[+] nailer|15 years ago|reply
Looks like he was already using Python - why didn't he try Tornado, which is built for purpose?
[+] amix|15 years ago|reply
We tried to use Twisted and it did not perform that well (too much CPU usage, too much memory usage). I think a similar limitation will be hit with Tornado, but I haven't tried it out. Most of Plurk is implemented in Python tho' and I would love a great Python solution.
[+] nc|15 years ago|reply
What about Scala and Lift?
[+] datapimp|15 years ago|reply
socket.io with node.js is working out very well for me. If you want to throw redis and rails in the mix, check out github.com/maccman/juggernaut
[+] admc|15 years ago|reply
+1
[+] silentbicycle|15 years ago|reply
Hello. It looks like you haven't participated much here. The HN community usually shuns these sorts of comments, because they don't really add to the conversation -- an upvote is already a "+1".