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.

So I've tried to understand how it worked and then, at the end, I have dealt with famous and notorious event loop. Moreover, during studying, I've also figured out that its operation was the same either when Javascript run in NodeJS than in the whatever Internet Browser.

The Event Loop

In 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 NodeJS

The 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.

NodeJS System

What the heck is the event loop anyway?

If you are interested to better understand event loop operation I recommend you to take a look to the following video.

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


Popular posts from this blog

POLYMER + TYPESCRIPT the marvelous couple

PlantUML & Maven - Enrich your project's documentation

PlantText: The new "Online" UML Editor powered by PlantUML