Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Node.js Event Loop Utilization & Delay Demos

Node.js License Profiler Education Status

A small practical repo to explore Node.js Event Loop performance using perf_hooks and eventLoopUtilization.

Note: For detailed explanations of each demo, including the code logic and expected behavior, see the 00-readme.md file inside the codes/ folder.


Overview

This repository demonstrates:

  • Measuring Event Loop utilization (ELU)
  • Monitoring tick time and mean delay
  • Understanding how heavy synchronous tasks affect the event loop
  • Dividing heavy tasks into chunks to prevent blocking

Installation

git clone https://github.com/Maryam-Skaik/nodejs-eventloop-perf.git
cd nodejs-eventloop-perf
npm install

Requires Node.js 14+


Demos

1. Event Loop Utilization

demo-eventloop-utilization.js Shows ELU metrics: idle, active, utilization, and mean delay. Helps detect ticks overloaded by heavy tasks or microtasks.

2. Chunking Heavy Code

demo-heavy-task-chunks.js Demonstrates splitting a heavy synchronous loop into smaller chunks using setImmediate to reduce tick length and prevent starvation.


Key Concepts

  • utilization: Percentage of time the loop is busy.
  • mean delay: Average delay between ticks.
  • Tick time: Actual time a tick took.
  • Tick capacity: Maximum amount of work a tick can handle before deferring tasks to the next tick.

Usage

Run a demo:

node codes/demo-eventloop-utilization.js
node codes/demo-heavy-task-chunks.js

Learning Outcome

  • Understand how Node.js event loop handles heavy tasks
  • Measure and interpret ELU metrics in real code
  • Learn how to split tasks to avoid blocking the loop

📜 License

This project is licensed under the MIT License
© 2025 Maryam Skaik


👩‍💻 Author

Maryam Skaik
GitHub Profile | LinkedIn

About

Node.js practical demos for exploring Event Loop performance and utilization using perf_hooks, measuring tick delays, and demonstrating task chunking to avoid blocking the loop.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages