Node.JS and IIS request mechanism (event-loop and threading)

I am trying to understand what is the advantage of the Node.JS event-loop mechanism (publish and subscribe to C ++ ThreadPool) in how IIS handles requests.

I read here: http://rickgaribay.net/archive/2012/01/28/node-is-not-single-threaded.aspx and the line: "There is no context switch because Event Loop just publishes and subscribes to the thread pool" . I do not understand.

IIS has an I / O stream that sends a request to the CLR thread pool, and continues to work until a response is received. The view is similar to a series of events from what I understood. The CPU switches between threads, so it switches to node workflows (to do the work) and is the same as the CLR thread pool.

Can someone explain what is the key advantage of the event loop mechanism over the request flow that uses IIS?

+4
source share
1 answer

I think the author you are referring to adds more confusion than clarity (the guy says he is just learning node, so you really ask for a blind, leading-blind situation in using this to learn), I don’t know why does he think that Node claims to be "this" (i.e. Node.js) is single-threaded. I have never seen this. The fact is that inside Node, your code is all executed in one thread, which means that the developer is freed from talking with different disagreements. (Many consider this a key advantage, but I think it can be argued that you are simply trading one type of template (for semaphores, etc.) For another: handling asynchrony (although there are several approaches to reduce the more tedious aspects of this).

Although I'm not quite sure what you are asking, I think if you watch this video ( https://www.youtube.com/watch?v=L0pjVcIsU6A ) between 3 minutes and 7 minute marks, you will have a moment "o , I get". The visual presentation that the presenter uses (which, it seems to me, he takes from the preso by the original creator of Node) is much easier to understand than a wall of text that would describe the same thing using only words.

Hope this helps.

0
source

Source: https://habr.com/ru/post/1481991/


All Articles