Hey Readers! I am SHIVAM :)
So, without wasting any time let's get started.
What is Node JS?
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:
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
- Open Source
- Can be used to develop data-intensive applications
- Asynchronous and Event Driven
- No Buffering
- Very Fast , and many more.
Now, after seeing the advantages let's explore the architecture of Node JS.
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...
Node.js is used for a wide variety of applications. Let's see some of them:
- Real-Time Chat Application
- Social Media Platform
- Online Payment Processor
- Single-Page Application
- E-Learning Platform
- Location-Based App
- CLI(Command Line Tools)
- API Servers and many more.
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!