Let's dive into the world of Node.JS !!!
While everyone is going mad about Node.js, let's understand why the developers and great IT giants across the globe are induced towards Node.js. Do you know Netflix, Uber, LinkedIn, and even NASA is part of the Node.js fanclub !!! Also, "PayPal" which is world’s largest and the most trusted services for financial transactions uses Node.JS as one of the technology. So, what is it so special about Node.js and its role in web app development? Let's dive into the world of Node.JS to find out the answer of this question .....
What is Node.JS ?
How does it Works ?
Traditional web-serving techniques where each connection (request) spawns a new thread, taking up system RAM and eventually maxing-out the available memory. Also in traditional systems "Multi-threaded request-response” architecture is an event loop which is much slower and unable to handle multiple concurrent threads at a time.
Unlike traditional techniques Node.js operates on a single-thread, using non-blocking I/O calls, allowing it to support tens of thousands of concurrent connections held in the event loop.
Now let’s understand each part of the Node.js architecture and the workflow of a web server developed using Node.js.
- Requests - Incoming requests can be blocking (complex) or non-blocking (simple), depending upon the tasks that a user wants to perform in a web application.
- Node.js Server - Node.js server is a server-side platform that take requests from users, processes those requests, and returns the response to the corresponding requests.
- LIBUV - Libuv is a C library that is used to abstract non-blocking I/O operations to a consistent interface across the platform. It provides mechanisms to handle file system, DNS, network, child processes, pipes etc. It also includes a thread pool for offloading work for some things that can't be done asynchronously at the operating system level.
- Event Queue - Event Queue in a Node.js server stores incoming client requests and passes those requests one-by-one into the Event Loop.
- Event Loop - Event Loop indefinitely receives requests and processes them, and then returns the responses to corresponding clients.
We should not miss to check what's npm?
npm is the World's Largest Software Registry !!!!
- npm contains millions of downloadable libraries for specific requirement. And the greatness of npm lies in the point that, all the libraries are absolutely free of cost. These libraries are getting bigger rapidly, making the Node.js community stronger day by day.
Below are the some of the most popular npm packages
Where we can use NodeJS ?
- Internet of Things (IoT) - NodeJS has less memory requirements so it can be easily integrated with controller boards like Arduino.
- Real time chat applications - If you choose to install the WebSockets on the server-side as well as on the client-side, Node.js is capable of carrying out real-time messaging with lower latency and faster data transfer. This ability can be used to build chat apps at a better level.
- Apps required for performing file operations - Node JS has one beautiful inbuilt module that is "fs" which makes the file operations like read, write, delete etc very easy for the developer.
Features that may attract you to Node.JS
- High Scalability - Node.js applications are easily scalable, vertically and horizontal. While vertical scaling lets you add more resources to the current nodes, horizontal scaling enables you to add new nodes quicker. Also the apps built in NodeJS can handle increasing number of connections.
- Gigantic open-source community and NPM repository (More than 1600000 packages) - A large number of software developers & many active Node.js geeks are constantly contributing to the evolving Node.js community to support the developers across the globe.
Like every programming platform/language, this one too has some cons !
- NodeJS shouldn't be used if you are going to develop application for heavy computation.
- Node’s relational database support tools are not up to the expected level when compared to other languages. This makes Node an undesirable for use cases with relational databases.
Thanks for reading !!!
Feel free to share your views in the comments section below. Please don't forget to check my other blogs :)
You can connect with me on Linkedin
Interested in reading more such articles from Hardeep Jethwani?
Support the author by donating an amount of your choice.