0% found this document useful (0 votes)
61 views3 pages

NodeJS Internals Student Notes

Node.js is a JavaScript runtime built on Chrome's V8 engine, enabling server-side JavaScript execution for scalable network applications. It utilizes non-blocking asynchronous programming and Libuv for managing the event loop and I/O operations, allowing efficient handling of multiple connections. Additionally, Node.js supports multithreading through Worker Threads and is well-suited for I/O-heavy, real-time applications.

Uploaded by

ddas4548
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views3 pages

NodeJS Internals Student Notes

Node.js is a JavaScript runtime built on Chrome's V8 engine, enabling server-side JavaScript execution for scalable network applications. It utilizes non-blocking asynchronous programming and Libuv for managing the event loop and I/O operations, allowing efficient handling of multiple connections. Additionally, Node.js supports multithreading through Worker Threads and is well-suited for I/O-heavy, real-time applications.

Uploaded by

ddas4548
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Node.

js Internals - Teacher Notes

What is [Link]?

[Link] is a JavaScript runtime built on Chrome's V8 engine. It lets developers run JavaScript on the

server-side. It's designed for building scalable, fast, and efficient network applications.

Why is [Link] Fast?

- Uses non-blocking, asynchronous programming

- Built on the fast V8 JavaScript engine

- Handles many connections using a single thread

[Link] Architecture

1. JavaScript Code

2. [Link] API (fs, http, etc.)

3. Libuv (event loop + thread pool)

4. OS Kernel (final execution)

Flow: JS Code -> Node API -> Libuv -> OS

V8 Engine

V8 compiles JavaScript to native machine code using Just-In-Time (JIT) compilation. It also handles memory

allocation and garbage collection.

Libuv & Event Loop

Libuv is a C library that manages:

- Event loop

- Asynchronous I/O

- Timers and callbacks

- Thread pool
[Link] Internals - Teacher Notes

The event loop allows [Link] to handle multiple operations concurrently without blocking the main thread.

Event Loop Phases

1. Timers (setTimeout, setInterval)

2. Pending Callbacks

3. Idle, Prepare

4. Poll (I/O events)

5. Check (setImmediate)

6. Close Callbacks

Microtasks like Promises and [Link] run between phases.

Thread Pool

[Link] uses a thread pool (default 4 threads) to perform blocking operations like file I/O, DNS lookup, or

crypto.

This is hidden from the user and managed by Libuv.

Worker Threads

Introduced in [Link] 10.5+, Worker Threads allow running JavaScript in multiple threads. Useful for

CPU-intensive tasks.

Non-blocking I/O Example

const fs = require('fs');

[Link]('[Link]', () => {

[Link]('File read!');

});

[Link]('Reading...');
[Link] Internals - Teacher Notes

Output:

Reading...

File read!

Module System

[Link] supports CommonJS (`require`) and ES Modules (`import`).

Core modules include: fs, path, http, crypto, etc.

Summary

- [Link] runs JavaScript using V8

- Uses Libuv for async I/O and event loop

- Handles many operations on a single thread

- Supports multithreading with Worker Threads

- Ideal for I/O-heavy, real-time applications

You might also like