Node js

it19214580 Bulner S.M.
3 min readMar 14, 2021

“Node.js is a packaged compilation of Google’s V8 JavaScript engine, the libuv platform abstraction layer, and a core library, which is itself primarily written in JavaScript.” Aside from that, Ryan Dahl, the Node.js developer, was trying to build real-time websites with push functionality, “inspired by applications like Gmail.” He gave developers a method to function in the non-blocking, event-driven I/O paradigm with Node.js.

Node.js excels in real-time web applications that use websockets and push technologies. What exactly is it about that that makes it so revolutionary? After more than two decades of stateless web based on the stateless request-response model, we now have web applications with real-time, two-way communications, allowing both the client and server to freely exchange data. This is in sharp contrast to the traditional web response model, in which the client is often the one who initiates communication. It’s also built on the open web stack (HTML, CSS, and JS) and runs on the standard port 80. With all of its benefits, Node.js has become a key component of many high-profile companies’ technology stacks.

How does it work ?

It’s fascinating how node js operates beneath the hood. Node.js runs on a single thread, using non-blocking I/O calls, allowing it to accept tens of thousands of concurrent connections kept in the event loop, compared to conventional web-serving strategies where each link (request) spawns a new thread, consuming device RAM and ultimately maxing-out at the amount of RAM available.

calculations show that on a machine with 8 GB of RAM, we can theoretically have 4,000 concurrent connections if each thread has an associated 2 MB of memory. plus the cost of thread-to-thread background switching In conventional web-serving strategies, this is the situation you’re most likely to face. Node.js reaches scalability rate of over 1M concurrent connections and over 600k concurrent websockets connections by eliminating all of this.

Where Node.js Should Be Used ?

Chat Applications

The most popular real-time, multi-user application is chat. From IRC (back in the day), to several proprietary and free protocols operating on non-standard ports, to today’s ability to incorporate anything in Node.js using websockets on port 80.

API on top of an object Db

Given the fact that Node.js excels at real-time applications, it’s a natural match for revealing data from object databases (e.g. MongoDB). Node.js will work without the impedance mismatch and data conversion because of JSON stored data.

Queued inputs

If you’re getting a lot of data at once, your database could become a bottleneck. As we now, Node.js can easily handle several concurrent connections. However, since database access is a blocking process, we have a problem. Before the data is truly written to the database, the remedy is to consider the client’s actions.

Data streaming

HTTP requests and responses are viewed as discrete events in more conventional web platforms; in fact, they are streams. This observation can be used to build some interesting features in Node.js. It’s possible to process files while they’re still being uploaded, for example, since data is received in a stream.

--

--