What is Node.js?
A stateless model is where the data generated in a session (such as information about user settings and events) are not preserved for use in the next session with that user. It takes a lot of work to keep the session information between requests a user But with Node.js, finally there is a way for web applications to have bi-directional connections in real time, in which both the client and the server can initiate the communication, allowing them to exchange data freely.
How does it work?
The only thread is the event loop that is responsible for executing all functions and requests. Asynchronous behavior is extremely important when the node is used because it ensures that the cycle of events is never blocked by a synchronous function. Although there is only one cycle of events, when a request is made, the cycle passes the request to an asynchronous function that the job When this function is completed and a response is returned, you can go to the event loop so that it is done by return call and sent to the user.
Why is Node.js popular?
Features of Node.js
These are some of the key features that make Node.js the first choice for software architects:
- With a single thread, but highly scalable: js uses a single-threaded model with an events loop. Node.js uses a single chained program, and the same program can provide service for a much larger number of requests than traditional servers, such as the Apache HTTP server.
- No buffering: Node.js applications never store buffer data These applications simply display the data in parts.
Advantages of Node.js
- js is an open source framework under the MIT license. (The MIT license is a free software license of the Massachusetts Institute of Technology (MIT)).
- Asynchronous by default. So it runs faster than other frames
- Cross-platform framework running on Windows, MAC or Linux