Event Loop in Node.js by @BusyRich

If you are a developer you have definitely heard about Node.js, and some keywords such as single threaded, non-blocking, and asynchronous IO. As opposed to other programming languages these features represent the core that the language is built on.

However, what a lot of new Node.js developers don’t take into account is how to make full use of the event loop and simply translate one language to another. In this article, I will demonstrate how the event loop can be blocked in a real-world application and show some tools available to prevent blocking.

What’s the Event Loop

Definitely check out this presentation from Philip Roberts “What The Heck Is The Event Loop Anyway” for a great visualization of asynchronous callbacks.

A Summary Of The Presentation:

Node uses the call stack to handle synchronous commands like most programming languages. Node makes use of V8 which will handle processing computing in another process known as WEB APIs. After the WEB API are finished the code will move to the callback queue and then move to the call stack to be executed.

It should be noted that this represents a high level of how the event loop operates. The actual implementation is better described here. As well as a great article on the misconceptions of the event loop.