Node.js – Handling CPU Intensive Web Applications

node.js

Some time ago I made this question about porting a Silverlight application to web. We lack experience working with web applications and have started to look for training and resources. We have noted that there is a strong trend about Node.js at the moment, and while we are aware its popularity and support, we have some doubts about its suitability for our needs. Our application would consist on one to several web applications, linked to different operational units in the company, each one performing several different functions. Some of these function, however, would include Reporting and Data analysis, requiring sometimes (but not always) long-running operations related to number crunching and transformation of significant amounts of data.

In the past, these cpu-expensive operations were managed client-side with Silverlight, but in our future set-up, they would be done in the server, and I have found several resources in the net pointing to possible problems that an application with these requirements might face in Node.js due its architecture. Of course, there is many other resources claiming that those problems do not exist or are easily solvable with certain module or offloading heavy tasks to another server. The last solution, however, would be difficult to implement for us due several reasons.

So now the question. Can Node.js manage applications required to perform CPU-intensive tasks as described?

The application started as a windows form application, but we were more or less forced to move to web due the higher ups decided it was the solution for several problems the application had, and they do not think that returning to a desktop application is an option. Also, we have little to no control over the production server(one server and one backup server that mirrors the first, with a load balancer) , and must trust the company that manage them to do all the installation. This mean that, to maintain our sanity and theirs, the set-up of the application should be as simple as possible.

Most of us have a background limited to .net desktop and Silverlight applications, and we have to rely on others for counsel in pure web applications. This question is only one of many we are trying to give an answer in order to have a clear understanding of what options we have available and the pros and cons of each one. As "What is the pros and cons of X" might not be an appropriate format for a question in this site, and since most of them are covered anyway all over the net, I decided to make the question about one of those points I was having more doubts.

Best Answer

The main problem that Node.js has in your usecase is that it runs on a single thread. This means that a CPU-intensive task has a great chance of blocking the whole server until it has finished.

On the other hand, you could use a task queue running on another server (or process), as described in this answer. If you do this, your client-facing server shouldn't block.