You mention a CPU-related task and a long-term one, which is definitely not a thing node.js. You also mention hundreds of simultaneous tasks.
You can take a look at something like the Gearman job server for such things - this is a special solution.
Alternatively, you can still control node.js requests, just donβt do the actual job.
If it is relatively acceptable to have lower than optimal performance, and you want to save your code in JavaScript, you can still do it, but you should have some kind of job queue - something like Redis or RabbitMQ comes to mind.
I think that the job queue will be a must for long, hundreds / sec tasks, regardless of execution time. Unless you can create this task on other servers / services / machines - then you do not care, your node.js API is just the front and the level of managing the cluster of tasks, then node.js works fine for work, and you need focus on the cluster of tasks, and then you could ask a more correct question.
Now node.js can be useful for you here, it can help manage and keep these hundreds of tasks, depending on where they come from (i.e. you can only allow requests to your task server for specific users, or limit functionality pause others, etc.
Zlatko
source share