Node.js for server to server communication
I am wondering if node.js is good for server side application wich is not actually communicating with browser, or browser communication is just an additional part of whole app used rather for management.
The idea is simple:
Server receives high amount of UDP traffic with short messages containing user data from another server.
For each message app performs DB lookup and filter out messages with userid's that are not on the whitelist.
Filtered messages are processed, wich result in another DB update, or sending data to another server.
Is such case, a good scenario to learn node.js, or maybe there is no benefit from it comparing to eg Java EE?
Disclaimer: I work for a company that contributes to node.js and promotes its usage, so my opinion might be biased.
As others mentioned in comments, node.js should be a good fit for you scenario. It is actually one of the most common scenarios where people use node.js - fetch data from (possibly multiple) sources, do a small amount of CPU-light processing and send back the response or store the result. Unless message filtering is very CPU expensive, node.js implementation will probably outperform J2EE version.
The reason is that Node.js is heavily optimised for solutions where the server spends most of the time waiting. Waiting for client connection, waiting for database response, waiting for disc read/write, waiting for client to read the response, etc.
J2EE is employing multi-threading, where you have one thread to handle each request, which is suboptimal in this case. Most threads are waiting, so you are not getting the benefit of running lots of code in parallel, but you still have to pay the price of context switching and higher memory usage.
There is one thing I would consider before going for node.js: are you able and allowed to deploy node.js into your production environment? Moving to a new platform has some associated costs, people operating your application will have to learn how to deal with node.js applications.
链接地址: http://www.djcxy.com/p/13536.html下一篇: 用于服务器到服务器通信的Node.js