Posts

Showing posts with the label Event Loop Node Single Thread

Single Thread Mystery - Node

Image
A Single Thread that handles multiple request ? I have been reading about threads and all the performance gain that you will have if you use multiple threads but there is Node which runs on a single thread. So i tried to investigate how node handles multiple request using a single thread. Event loop Architecture Node uses an event loop architecture. It specifically uses a non-blocking I/O event model. This means the thread of execution will not block if it is an I/O event. But what is an I/O event for Node ? Well all http requests, database queries, file manipulation [ 1 ] In my mind i picture node like these (The diagram is based on a typical process structure)  Code - program code Data - variables of the program Files - file pointers (I am not sure about if node keeps file pointers at the process level) After trying to picture this out, several questions pop in to my mind.  How will node be able to utilize a multiprocessor hardware ? Node has &qu