Loading, please wait...

Introduction of Node.js


Node.js is an open-source server-side runtime environment. It is built on Chrome's V8 JavaScript engine. It gives an event-driven, non-blocking (asynchronous) I/O and cross-platform runtime environment for building a server-side application using JavaScript. It’ is designed to build scalable network applications. It is designed to handle many concurrent connections at an instant.

Node.js is mainly used to build network programs (like a web server, PHP, Java, ASP.NET). It can also be used to build different types of application likes command line application, web application, real-time chat application, REST API server etc.

Node.js = Runtime Environment + JavaScript Library

Node.js Architecture:

Figure 1 Node.js Architecture

Node.js follows single-threaded event loop architecture. Model of Node js mainly based on JavaScript Event based model with JavaScript callback mechanism.

Node.js comprises two main component core & its modules.

  • Core: it’s built-in C & C++. It combines Google V8 JS engine with Node’s Libuv library and protocol bindings including sockets & Http.
  • V8 Engine: Runtime Environment: It’s an open source JIT (Just in Time) compiler written in c++ which has outperformed PHP, Ruby and python performance wise. V8 compiles JavaScript directly into assembly level code. 

Different Features of Node.js:

  1. Asynchronous and Event Driven - All APIs of Node.js library is asynchronous, that is non-blocking. The server can respond to more than one requests at a time. It won’t end or block any API request and will respond to all when the response is prepared to ship  Everything is a tournament (state) based. Such kind of approach will fireplace callback (functions most of the time) as the event show up (state changes). A tournament based gadget is usually in the circular loop to execute it’s duties as defined in the example
var fs = require ('fs');

          fs.readFile ("input.txt", function (error, data)


               console.log ("Hello World");


  • The above code looks at reading a file referred to astxt. (function (error, data)) is referred to a callback function.
  • The file reading operation will begin in the background, and different processing can happen simultaneously whilst the file is being read. Once the file read operation is completed, the nameless feature will be known as and the textual content "Hello World" will be written to the console.log.
  1. A very Fast − Node.js library is very fast in code execution as built on Google Chrome's V8 JavaScript Engine
  2. Single Threaded but Highly Scalable − Node.js uses a single threaded model with event looping. This Event mechanism helps the server to respond in a non-blocking way and it also makes the server highly scalable.
  3. No Buffering – In Node.js applications buffering is not required in any data. These applications simply output the data in chunks.

 Node.js application areas:

  • I/O bound properties
  • Data Streaming Applications
  • Data Intensive Real-time Applications(DIRT)
  • JSON APIs based Applications
  • Single Page Applications