Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Node.js for server to server communication

I am wondering if node.js is good for use in a server side application which is not actually communicating with the browser, or browser communication is just an additional part of whole app used rather for management.

The idea is simple:

  1. Server receives high amount of UDP traffic with short messages containing user data from another server.

  2. For each message app performs DB lookup and filter out messages with userid's that are not on the whitelist.

  3. Filtered messages are processed, which 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 e.g Java EE?

like image 253
Kamil Z Avatar asked May 16 '13 11:05

Kamil Z


People also ask

Is node js good for networking?

Node. js is a single-threaded, open-source, cross-platform runtime environment for building fast and scalable server-side and networking applications. It runs on the V8 JavaScript runtime engine, and it uses event-driven, non-blocking I/O architecture, which makes it efficient and suitable for real-time applications.

How node js works on server-side?

Node. js is a JavaScript framework for writing server-side applications. In its simplest form it allows you to trigger small JavaScript programs from the command line without any browser involved. For example, assuming node is installed if you write a JavaScript program in a file called hello.

Is node js used for server?

Developers use Node. js to create server-side web applications, and it is perfect for data-intensive applications since it uses an asynchronous, event-driven model. Now that we know what is Node, let's look at why it is so prevalent in web development.


1 Answers

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.

like image 138
Miroslav Bajtoš Avatar answered Oct 15 '22 22:10

Miroslav Bajtoš