Node.js vs Java for Comet application [closed]

2019-03-08 08:53发布

问题:

We look to build a high-performance, scalable Comet server, and thought first about using Java Grizzly with GlassFish.

But after some research, we see that Node.JS is taking rapidly as the preferred choice due to extreme simplicity, and claimed performance:

http://news.ycombinator.com/item?id=1088699

http://amix.dk/blog/post/19484

I will be happy to hear some real-life experience of using both, and what ultimately can be the best choice down the road.

Thanks!

回答1:

If you would further read the blog posts by the same author, namely the post, Is node.js best for Comet, he explains why he again went back to the Java based solution (Netty) and is happy with it. I guess that would be an interesting read.



回答2:

I know this is an old and already answered question but I think my experience can be helpful.

I started a little pet project to test Node.js - how it "feels" and how to program on it. I became impressed by the ease of working in such ecosystem: Node.js code is easy to write (although its asynchronous paradigm is not that straightforward for the conventional programmer), libraries are easy to build etc. etc. Even npm is amazingly easy: I just found the most straightforward way to provide code of your own as a library is to make a public package of it!

However, there is not much good tools to work with Node.js. Maybe because it is too easy to do anything, most libraries are partially-implemented, undocumented solutions (and I am guilty too).

Also, note that the relevant difference of Node.js is not the JavaScript language, but the asynchronous I/O model. It is the most interesting aspect of Node.js, but the asynchronous programming style is not as well tested as the conventional way of web development. Maybe it is really the marvel that is propagandized - or perhaps, it is not as good as promised.

Even in the case it pays off, will you have enough developers to maintain such an (at least still) unusual codebase? If you can get a lot of advantages from the asynchronous "way of life" of Node.js, you can use more consolidated languages and frameworks, such as Twisted for Python (which is my preferred languabe, so take care with my opinion :) ). There may be something like this for Java, too. Anyway, I suspect that you do not have a lot of interest in this model for now, since your question focuses more on languages than in the programming paradigm, so Node.js does not have much to offer to you anyway.

So... no, I would not develop something professonaly in Node.js for now, although I think it is both fun and instructive to study.



回答3:

In my opinion the asynchronous approach for Comet glorified in Node.JS and Grizzly is deeply flawed.



回答4:

In a more recent test (August 2012), Node.js was able to handle 1 million single connections from a single 16GB RAM Server.

http://blog.caustik.com/2012/08/19/node-js-w1m-concurrent-connections/