Shivam Katare
Shivam Katare's Blog

Shivam Katare's Blog

What Exactly Is Node.js?

What Exactly Is Node.js?

Shivam Katare's photo
Shivam Katare
·Jun 25, 2022·

3 min read

Table of contents

  • What is Node JS?
  • Why Node JS?
  • Advantages Of Node JS
  • Architecture
  • Node JS Can Build...
  • Conclusion

Hey Readers! I am SHIVAM :)

Today, we are going to discuss Node.js, which is an extremely powerful JavaScript-based platform used to develop online chat applications, video streaming sites, single-page applications, and many other I/O-intensive web applications and web apps.

So, without wasting any time let's get started.

What is Node JS?

shopify-2.png

Node.js is a platform built on Chrome's JavaScript runtime for easily building fast and scalable network applications. Node.js uses an event-driven(An event-driven application is a computer program that is written to respond to actions generated by the user or the system), non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices.

Node.js is open-source and completely free, used by thousands of developers around the world. It brings plenty of advantages to the table, making it a better choice than other server-side platforms like Java or PHP.

So, this is the simple definition of NodeJs. Now let's see why we should use Node js.

Why Node JS?

  • There are several reasons to use Node JS, some of them are:

  • Node.js is fast: Having been built on Google Chrome's V8 JavaScript engine, its library is fast for code execution.

  • Highly scalable: The node.js server responds in a non-blocking way, making it highly scalable in contrast with traditional servers, which create limited threads to handle requests.

  • Node Package Manager (NPM): Node Package Manager has more than 50,000 bundles, so whatever functionality is required for an application can be easily imported from NPM.

Now, let's see some of the advantages of the Node JS

Advantages Of Node JS

  1. Open Source
  2. FullStack JavaScript
  3. Can be used to develop data-intensive applications
  4. Asynchronous and Event Driven
  5. No Buffering
  6. Very Fast , and many more.

Now, after seeing the advantages let's explore the architecture of Node JS.

Architecture

node.js-architecture.png

Node.js operates on a single thread(The execution of an entire task from beginning to end without interruption.), allowing it to handle thousands of simultaneous event loops.

Here are the steps to understand Node JS (You can also see it on the diagram above).

  • Node.js maintains a limited thread pool to serve requests.
  • Whenever a request comes, Node.js places it into a queue.
  • Now, the single-threaded “Event loop”—the core component—comes into the picture. (this event loop waits for requests indefinitely).
  • When a request comes in, the loop picks it up from the queue and checks whether it requires a blocking input/output (I/O) operation. If not, it processes the request and sends a response.
  • If the request has a blocking operation to perform, the event loop assigns a thread from the internal thread pool to process the request. There are limited internal threads available. This group of auxiliary threads is called the worker group.
  • The event loop tracks blocking requests and place them in the queue once the blocking task is processed. This is how it maintains its non-blocking nature.

Since Node.js uses fewer threads, it utilizes fewer resources/memory, resulting in faster task execution. So for our purposes, this single-threaded architecture is equivalent to multi-threaded architecture. When one needs to process data-intensive tasks, then using multi-threaded languages like Java makes much more sense. But for real-time applications, Node.js is the obvious choice.

Now you know what is Node JS, and why we should use it? So, now at last we will gonna talk about, what we can build from Node JS?

Node JS Can Build...

nodejs3.jpg

Node.js is used for a wide variety of applications. Let's see some of them:

  1. Real-Time Chat Application
  2. Social Media Platform
  3. Online Payment Processor
  4. Single-Page Application
  5. E-Learning Platform
  6. Location-Based App
  7. CLI(Command Line Tools)
  8. API Servers and many more.

Conclusion

So, that's the wrap-up for this blog, this was something about Node JS. Hope you enjoy reading, and learn something from it.

Did you find this article valuable?

Support Shivam Katare by becoming a sponsor. Any amount is appreciated!

Learn more about Hashnode Sponsors
 
Share this