Node.js event loop

Christopher Kade

Inspired by James Snell's talk at CascadiaJS 2018

@christo_kade

What's the point of this presentation?

Understanding precisely how this part of Node works

Debugging efficiently my Node projects

Two parts:

  • Summing-up the Event Loop
  • The Event Loop's architecture

Summing-up the Event Loop

The Event Loop executes only one task at a time

Event Loop

C++

Javascript

Event Loop notification

NTQ

MTQ

process.nextTick(callback)

.then()

 .catch()

 .finally()

When Javascript is running, the Event Loop is not

a.k.a the Event Loop Delay

The Event Loop's architecture

setTimeout(callback)

setInterval(callback)

Accepting new connections & data related calls

Callbacks linked to closing of sockets etc.

Things to remember:

  • The Event Loop executes only one task at a time

  • When Javascript is running, the Event Loop is not (both on a single thread)

  • The Event Loop is composed of more than one queue (or queue-like structure)

Thank you for your attention !

References:

Node.js event loop workflow & lifecycle in low level - http://voidcanvas.com/nodejs-event-loop/

Observing NodeJS - https://www.youtube.com/watch?v=V0LcfB-H0aY&t=

Node.js Event Loop (English)

By christopherkade

Node.js Event Loop (English)

  • 186
Loading comments...

More from christopherkade