How to handle CPU-intense tasks with Node.js?

Updated: October 2017

When you read about what Node.js is good at it usually goes like this: "Node.js is great for a WebServer. A main part of almost all web-applications is to create, read, update and delete things in the database. Multi-threaded languages have a large memory overhead with this, since e.g. for 1000 requests they create 1000 threads. Since Node.js is single-threaded and non-blocking, you can achieve higher concurrency with the same resources".

And when you read about what it's bad at it usually goes like this: "Since Node.js is single-threaded, CPU-intensive tasks will block all requests from completing, until the task is completed. Therefore Node.js isn't a good solution for CPU-intense tasks".

So does that mean, when first designing your new web-application you have to choose between a system that loses a lot of memory due to threads or one that can't run CPU-intense tasks?! Of course it doesn't. For one, Node.js isn't the only option out there allowing for high concurreny. You could for example implement a WebServer in Golang or even implement a non-blocking Java server. But also with Node.js you aren't stuck with only simple create / read / update / delete requests. The solution to this problem is a task queue.

There are also related StackOverflow and Quora questions:

Dear Devs: You can help Ukraine🇺🇦. I opted for (a) this message and (b) a geo targeted message to Russians coming to this page. If you have a blog, you could do something similar, or you can link to a donations page. If you don't have one, you could think about launching a page with uncensored news and spread it on Russian forums or even Google Review. Or hack some russian servers. Get creative. #StandWithUkraine 🇺🇦
Dear russians🇷🇺. I am a peace loving person from Switzerland🇨🇭. It is without a doubt in my mind, that your president, Vladimir Putin, has started a war that causes death and suffering for Ukrainians🇺🇦 and Russians🇷🇺. Your media is full of lies. Lies about the casualties, about the intentions, about the "Nazi Regime" in Ukraine. Please help to mobilize your people against your leader. I know it's dangerous for you, but it must be done!