You might be wondering if the title of this article is a bit ambitious, but fear not! I’ve put in the time and effort to cover everything you need to know about the EventLoop in Node.js. And believe me, you’ll discover so many new things along the way!
Before beginning this article, I’d like to inform you that it’s important to have a basic understanding of Node.js and its EventLoop to fully comprehend the core concepts discussed.
This comprehensive guide is going to take some time to cover every detail that you need to know, so grab a cup of coffee and settle in for an exciting journey to the fascinating world of Node.js. Let’s get started!
Here is the list of topics covered in this article.
— What is Node.js
— Reactor Pattern
— Node.js Architecture
— Event Queues (I/O Polling, Macrotasks, Microtasks)
— Changes from Node v11
— CommonJS vs ES modules
— Libuv (thread pool)
— DNS is problematic in Node.js
— Custom Promises — Bluebird
— Summary
What is Node.js
If you take a look at the official documentation, you’ll find a brief explanation like this.
Node.js is a JavaScript runtime built on Chrome’s V8 JavaScript engine. It uses an event-driven, non-blocking I/O model that makes it lightweight and efficient.
Well, that brief explanation doesn’t tell us much, does it?
There are so many important details and concepts related to the EventLoop in Node.js that require a more in-depth explanation.