In this tutorial, we will discuss about NodeJS, Architecture of NodeJs,
advantage and disadvantage of NodeJS.
- NodeJS Introduction
- NodeJs Architecture
- Advantage of NodeJS
- Disadvantage of NodeJS
- Ryan Dahl developed Node JS in the year 2009
- NodeJS js is not a programming language. It is a runtime environment.
- NodeJS can be runs on various platforms like Windows, Linux, Unix, Mac OS X,
- If we create a .JS file in our system and want to run that file we can use
node.js. So it provides runtime enviroment.
- NodeJS is commonly used for Backend Social Networking, Sinple page
application, Chat Applications, Data Streaming etc.
- NodeJS runs single threaded, non blocking, asynchronous programming which
is very memory efficient.
- NodeJS eliminates the waiting, and simply continues with the next request.
- There are many companies which use NodeJS like Netflix, NASA,
Trello, PayPal, LinkedIn, Walmart, Uber, Twitter, Yahoo, eBay, GoDaddy.
Google uses NodeJS in its search indexing service.
ability to run on the computer, instead of the browser. This is made
- Node.js is built on the V8 engine of Google. It is the fastest
machine code, which the computer understands. The result is then generated
and returned to node.js.
- Node.js uses asynchronous programming.
Problem with A Typical Web application
Assigning Independent Threads to Each Request is an Expensive Task. In
technologies like C# and Java, each request is processed with an independent
Thread. The problem with the approach is that Server has Fixed No of Threads in
the Thread Pool. Therefore at any moment of time, Maximum Request processed are
equal to number of Threads in Thread Pool.
The following diagram show the how NodeJS handle multiple concurrent
request using single-threaded event loop architecture.
Components of the Node.js Architecture:
- Requests - User send the requests to the server can be either blocking (complex
or heavy) or
- Node.js Server - The Node.js server accepts user requests, processes them and returns results to the users.
- Event Queue - Event Queue is used to store the
incoming client requests and pass them sequentially to the Event Loop.
- Thread Pool - The Thread pool in a Node.js server contains
the threads that are available for performing operations required to process
- Event Loop - Event Loop receives requests from the Event
Queue and sends out the responses to the clients.
- External Resources - In order to handle blocking client
requests, external resources are used. They can be of any type (
In the above image,
when the request hits the node server, it will go
to the event loop through the event queue. The event loop will now check whether
the task is heavy, like operations dealing with files or network-related
operations. If the task is heavy it will offload it to the thread pool, where
the thread pool will execute the task separately. it will not block our event
loop, and the event loop can perform all the less complex tasks. So Asynchronous
and Non-blocking of I/O operations features enhance the scalability,
performance, and throughput of Node.js web applications.
code that enhance performance for Real-time Applications.
- Easy Scalability for Modern Applications
- Large Community Support to Simplify Development. Nodejs is supported on
Github which makes it super easy and fast to develop and support the
- Easy to Learn and Quick to Adapt.
- Nodejs is compatible with desktop, mobile, and web development for Mac,
Windows, and Linux.
- Nodejs along with npm libraries Boosts development speed
- Helps in Building Cross-Platform Applications
- Node.js Reduces performance when handling Heavy or complex Computing
- Node.js Asynchronous Programming Model makes it difficult to maintain
- High demand with a few Experienced Node.js Developers in the market.