How does single-threaded node performs better than multi-threaded apache/nginx?
But if you consider the below code:
setTimeout(function () { for (var i = 0; i < 1000000000; i++){} }, 1000);
Imagine that the above code is inside my server script. I've placed a 1 second timeout which is non blocking, but after that I've placed a great loop that blocks the entire thread for a long time.
In between that loop, if a new request comes, then what will happen? Node.JS will create a new instance of my server, right? So, Node.JS itself can't be single threaded because its already busy with my loop. So overall, how many threads is my entire app (including the V8 engine) consuming?