What is Node.js

Multiple Node.js vulnerabilities fixed in flurry of new releases | The  Daily Swig

  • Google V8 JavaScript engine
  • High-performance network server
  • Single-threaded event loop-based architecture
  • Non-blocking I/O processing
  • JavaScript language
  • Improved development productivity
  • Vast module library provided by NPM 

Node.js is a software platform used for developing scalable network applications, particularly server-side applications.

It uses JavaScript as its programming language and has high processing performance through non-blocking I/O and a single-threaded event loop. 

It includes an embedded HTTP server library, making it possible to run a web server without separate software such as Apache, enabling greater control over web server operation.

The most important feature of Node.js is its single-threaded event loop-based architecture, which is different from the thread-based synchronous architecture that Java developers may be more familiar with. In a thread-based synchronous architecture, one thread waits for a request to be processed before moving on to the next request.

If there are many concurrent requests, multiple threads are needed, which can lead to server overload. In Node.js, when a request is received, the event loop immediately sends a request for the next processing step and continues processing other requests until the first request is completed. 

This allows Node.js to handle multiple requests without waiting for each one to be completed, resulting in lower server load.

Advantages:

  • Using JavaScript for server-side logic allows for faster development and application of server technologies without having to learn a new language.
  • Non-blocking I/O and single-threaded event loop architecture provide high processing performance.
  • Node.js is lightweight and runs efficiently even on a local machine.
  • Node.js uses an event-based asynchronous architecture, resulting in lower server load.
  • NPM provides a variety of modules and packages to use.

Disadvantages:

  • As Node.js is event-driven and asynchronous, server-side logic can become complex and fall into the "callback hell" when there are multiple logical processes that depend on results from a single database query.
  • Programming and designing for Node.js require a different approach from traditional Java development due to its non-sequential event-based processing model.
  • Node.js is not suitable for web services that involve long-running tasks as it is a single-threaded environment.
  • Node.js is more suitable for lightweight I/O-intensive web services, such as those with many simple I/O requests.
  • As Node.js crashes the process when an error occurs, rigorous testing of all possible cases is crucial.

Web services that are suitable for Node.js:

  • Simple logic
  • High concurrency demands (processing multiple requests simultaneously)
  • Fast response time requirements
  • Rapid development demands
  • Services that are suited to an asynchronous processing model, such as network streaming and chat services.

Web services that are not suitable for Node.js:

  • Services that involve long-running tasks as it is a single-threaded environment.
  • Services that involve a lot of server-side checking logic as they may fall into callback hell.
  • Services with high complexity or difficulty as code quality is crucial in preventing crashes.

Companies that use Node.js:

 Netflix, LinkedIn, PayPal, Uber, and Facebook actively use Node.js in their services.

 

references:

https://en.wikipedia.org/wiki/HTTP#HTTP_session

https://nodejs.org/en/about