NodeJS - Event Loop unveiled
NodeJS : An asynchronous single threaded environment 😮When started to work with nodeJS i was surprised that it was advertised as "asynchronous single threaded" environment.
The Event LoopIn the image below has shown the basic event loop schema that make clear the architectural choices behind the callback model (and as consequence the callback hell).
In fact such model allows to decouple the event loop thread, where the main application runs, from all the resource consuming operations.
|Basic Event Loop Schema|
Event Loop in NodeJSThe image below adds more details to the previous one in particular, concerning event loop, we find out event queue and worker threads that give us a bit more info about its operation.
If you are interested to better understand event loop operation I recommend you to take a look to the following video.
What the heck is the event loop anyway?
Really this video has inspired such article and it will give you a very clear understanding of all I've briefly explained before ...
So... enjoy this amazing video 😉
Philip Roberts: What the heck is the event loop anyway? | JSConf EU 2014