Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

node.js

What is the architecture and workflow of Node.js?

ACHONWA ALVAN

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Overview

Node.js is a platform built on a JavaScript foundation. It operates on the JavaScript V8 engine present in Google Chrome. It helps us develop web and single-page applications. Node.js is used by both large organizations as well as upcoming start-up companies.

Node.js architecture

Node.js architecture uses the 'single-threaded event loop' architecture for handling multiple client requests.

Node.js architecture

Parts of the Node.js architecture

  1. Node.js server: The Node.js server receives user requests, processes them, and sends feedback to the users. It is the server-side of the platform.
  2. Event queue: The event queue helps in request handling. It arranges incoming requests and sends them for processing one after the other.
  3. Requests: These are the tasks users try to perform on web applications. They are sent to the web application's server.
  4. Thread pool: These are the number of available threads used to carry out every incoming request by the user.
  5. Event loop: The event loop receives requests from clients, processes them, and sends them back to the client.
  6. External resources: These are resources that help perform client requests. The request could be computational or requires data storage.

Workflow in Node.js

Workflow in Node.js
  1. A request is sent to the server by the client. The request could be to delete data, query data, update data, and so on.
  2. The request is received by the event queue and kept for processing.
  3. The events are sent in the order they were received through the event loop. A check is also performed to know if any event requires external resources.
  4. The event loop processes the request (input/output) output polling and sends the feedback to the client.

Advantages of using Node.js

  1. Fewer resources are required in the operations carried out in the Node.js server.
  2. Node.js can handle multiple concurrent requests with ease. This is made possible through the event queue and the thread pool.
  3. Node.js does not need multiple threads because the event loop helps handle the events one after the other.

RELATED TAGS

node.js

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring