Node.js is an event-based platform which means that everything that happens in Node.js is the reaction to an event. The event loop is called the heart of Node.js.
A Node.js app runs in a single process, without creating a new thread for every request. Node.js provides a set of asynchronous I/O primitives in its standard library that prevent JavaScript code from blocking and generally, libraries in Node.js are written using non-blocking paradigms, making blocking behavior the exception rather than the norm.
Components of the Node.js Architecture:
- Requests: Depending on the actions that a user needs to perform, the requests to the server can be either blocking (complex) or non-blocking (simple).
- Node.js Server: The Node.js server accepts user requests, processes them, and returns results to the users.
- Event Queue: The main use of Event Queue is to store the incoming client requests and pass them sequentially to the Event Loop.
- Thread Pool: The Thread pool in a Node.js server contains the threads that are available for performing operations required to process requests.
- Event Loop: Event Loop receives requests from the Event Queue and sends out the responses to the clients.
- External Resources: In order to handle blocking client requests, external resources are used. They can be of any type ( computation, storage, etc).
Source: https://nodejs.dev/en/learn/
Source: https://www.geeksforgeeks.org/node-js-web-application-architecture/
Source: https://litslink.com/blog/node-js-architecture-from-a-to-z