Seidor
chica programando

June 05, 2024

What is Node.js and what is it used for?

Node.js is a JavaScript environment that allows us to execute on the server, asynchronously, with an event-driven architecture and based on Google's V8 engine. It is a platform that is advancing very quickly and is increasingly present in the market.

How does Node.js work?


The V8 engine compiles JavaScript into native machine code instead of interpreting it in the browser, thus achieving much higher speed. Node is open source and can run on Mac OS X, Windows, and Linux.

Server-side JavaScript


Traditionally, JavaScript has been used only for minor tasks in the browser, but it is now a programming language as powerful as any other. Additionally, JavaScript has an excellent event model ideal for asynchronous programming.

JavaScript is a language known by millions of programmers, so the learning curve for Node is reduced, as it is usually not necessary to learn a new language.

Asynchronous programming


In addition to high execution speed, Node.js has the Event Loop, which will allow managing enormous amounts of clients asynchronously. Traditionally, to work asynchronously, applications relied on programming threaded applications, but this usually involves the inefficient use of memory space that scales as the number of clients connected to our application increases.

Generally, each thread involves the use of 2MB of memory, which in an 8GB RAM system means a theoretical maximum of 4,000 user connections. Therefore, if we need to manage large amounts of connections, we will have to increase the number of servers.

The Node solution


Node.js solves this problem by changing the way connections to the server are made. Instead of generating a new I/O thread for each client, each connection triggers the execution of an event within the Node engine process. In this way, Node allows a single server running it to support tens of thousands of connections.

Thanks to Node, LinkedIn went from using 30 servers to just 3!

Maybe it might interest you

June 05, 2024

What is Redis?

Redis is an open source database engine with a BSD license. It operates using hash tables (key – value) and can be used as a persistent database.

SEIDOR
June 05, 2024

What is ElasticSearch?

ElasticSearch is a document-oriented search engine that allows us to index a large volume of data to be able to query them later.

SEIDOR