DEV Community

Discussion on: Everything you need to know about Node.js

Collapse
 
jorge_rockr profile image
Jorge Ramón • Edited

According to Microsoft's official documentation:

For example, in Windows an OS thread makes a call to the network device driver and asks it to perform the networking operation via an Interrupt Request Packet (IRP) which represents the operation. The device driver receives the IRP, makes the call to the network, marks the IRP as "pending", and returns back to the OS. Because the OS thread now knows that the IRP is "pending", it doesn't have any more work to do for this job and "returns" back so that it can be used to perform other work.
When the request is fulfilled and data comes back through the device driver, it notifies the CPU of new data received via an interrupt. How this interrupt gets handled will vary depending on the OS, but eventually the data will be passed through the OS until it reaches a system interop call (for example, in Linux an interrupt handler will schedule the bottom half of the IRQ to pass the data up through the OS asynchronously). Note that this also happens asynchronously! The result is queued up until the next available thread is able to execute the async method and "unwrap" the result of the completed task.
Throughout this entire process, a key takeaway is that no thread is dedicated to running the task. Although work is executed in some context (that is, the OS does have to pass data to a device driver and respond to an interrupt), there is no thread dedicated to waiting for data from the request to come back. This allows the system to handle a much larger volume of work rather than waiting for some I/O call to finish.

Please note there is no thread dedicated to waiting for data from the request to come back, so that means they are not using Reactor Pattern (i.e. an Event Loop), they are really using purely OS resources (threads and interrupts) and that is awesome!!

I don't know if that's enough to solve C10M problem, maybe with big server resources such as 128 RAM, etc.