CHAPTER TEN
The Node.js Event Loop
If you’re using Node.js, chances are that you started tinkering with it after getting tired of hearing everyone rave about this platform for building fast servers using JavaScript.
You went on the Node.js website and read this: “Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.”
Now, if you have experience building event-driven servers, this will already make enough sense to you. (And this chapter is probably not for you!) However, if you’re like me, when you read this you probably decided to quit programming, because here’s a platform for developers and I’m a developer, but I’m too stupid to understand why I should care!
Okay, maybe that was a little bit of an exaggeration. You didn’t quit programming, and you’re not stupid for not understanding why you should care about Node.js.
My goal is that, by the end of this chapter, you will be proud to tell the world you understand how the Node.js event loop works and start receiving your much-deserved LinkedIn endorsements for “Node.js event loop.”
Event-Driven Programming
At a high level, event-driven programming is when a system expresses its interest in a particular set of events, provides a way to be alerted when said events happen, and responds to them using callbacks.
What do these terms mean, though? An event is some change in a system’s state. ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access