CodeSteps

Python, C, C++, C#, PowerShell, Android, Visual C++, Java ...

Node.js – An Introduction

Node.js is an Open Source JavaScript run-time environment that allows to run JavaScript code. It provides cross-platform run-time environment.

It was originally developed by Ryan Dahl in the year 2009.

We can use Node.js in developing Single page Web applications to High performance applications. Main focus of Node.js is to create highly performance applications. Unlike other technologies; AJAX, jQuery etc., Node.js uses Single Thread Event model to handle concurrent client requests. This thread pool handles the execution of parallel Tasks. Don’t understand? Look at below explanation.

Whenever you send a web request to the Traditional Web Servers; they spin up a new process to handle each web request. This consumes lot of CPU power and RAM; leads to an expensive operation. Yes, it takes time to create a new process, run the web request in the new process and returns the response to the web request. Instead of this, modern web servers use a thread from a thread pool to respond to each web request.

Using a thread in a thread pool saves the overhead of creating a new process for each web request. Again there is performance problem with this approach. Context switching between threads results lot of CPU consumption. So, what Node.js do then?

The way Node.js handle the requests

Node.js works on the principle that, handling each web request in a single thread; instead of using a thread from a thread pool or creating  a new process for each web request. That said, Node.js is a single-threaded web server and capable of handling concurrent requests.

Node.js is event driven; responds when an Event occurred which allows to provide real-time execution of the Tasks. Node.js has Event loop to handle each generated Event.

Before I close this Article, would like to mention that; Node.js uses V8 JavaScript engine to execute JavaScript. V8 JavaScript engine is part of Google Chrome Project.

Finally; Node.js files are JavaScript files with the extension “.js”.

</> Michael

Node.js – An Introduction

One thought on “Node.js – An Introduction

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top
Exit mobile version