Introduction to Node.js

it19167992 Wanigasekara S V
2 min readMay 29, 2021

Nodejs developed by Ryan Dhal. He is Initial author of Node.js and its now Community driven.Node.js is single threaded and it has non blocking I/O Programming language. That mean It would not block I/O operations.node .js use v8 java script engine.node.js is open source cross platform run time environment.Node.js Run time is very light weight.node.js can run almost any ware.Node.js have set of inbuilt libraries .When we install node.js by default get them all libraries it to machine/ programming run time. That libraries we can use to do most of task like deal with file systems operations, Operating system related data, information, network HTTP programing. NodeJS has largest set of open source library. We called it as npm(node package manager)repository. That is the largest eco system to the day. It passes no of libraries available in such as Maven, NuGet. npm library is another advantage that we get from NodeJS because of huge number of library available to use in the programs and disadvantage is design libraries are low.Node.js can add, edit, delete data to database and collect form data.

NodeJS is Single thread .So ,thread not waits for I/O operations to complete instead it will hand it over to internal thread pool and let be main operations to complete. Nodejs not best platform to CPU heavy or computational heavy application.

Nodejs Non Blocking Event loop

Hundred thousand requests come same moment in few seconds. one thread can do one thing on given time because of single thread. This cannot have multiple operations running parraral. But some mechanism to achieve to that. NodeJS capable to doing that.

Main CPU get request and check I/O operation or not. If I/O operation main thread not getting block and starts operations but main thread Free.it can do any something else. When I/O coming it pass to Event loop and keep main thread free. After finish I/O operation if main thread is free it switch back and get output the I/O operation and return it to the client. But main thread cannot be interrupted. If it is working something it will continue work on that one. Once it finish look in to the event queue and see whether their completed operations. If main thread available it can look into any request coming or any completion operations on the event queue only during the free period.

--

--