Introduction to NodeJS and Its Request Processing Model


           In this article, we will see the basic introduction of NodeJS and Its request processing model. NodeJS is a server-side Javascript run time built on top of Chrome’s V8 engine. Node run time is an event-driven, asynchronous and nonblocking I/O, that provides a lightweight environment. As opposed to traditional web servers, NodeJs uses single thread event loop to process the requests.

Now let us understand how NodeJS process the requests by following the below diagram.

NodeJS Request Processing

             From the above diagram, all the requests which are going to NodeJS server will be maintained in “Event Queue“. The “Event Queue” will be processed by “Event Loop” which will run with a single thread. The “Event Loop” will take requests from the “Event Queue” and the response will be given back to the client. The “Event Loop” will run infinitely to complete the requests available in the queue. If there are no requests in the queue, the event loop will be an ideal state. For example, the request R1 is a nonblocking I/O request, then the event loop will return the response immediately to the client. In the above diagram request R2 is expecting information from external systems like database/file system, then the event loop will leave that request to the “Node Internal Thread Pool”.  A thread from the thread pool will take the request R2 to process. Whenever the request R2 is ready with the data, then the thread handover the request R2 to the event loop. Then the event loop will send the response back to the respective client. This is how NodeJS server handles multiple requests with “Single Threaded Event Loop“.

             In the coming articles, we will see the NodeJS running environment with examples. Till then, Happy Learning!!!

Siva Janapati is an Architect with experience in building Cloud Native Microservices architectures, Reactive Systems, Large scale distributed systems, and Serverless Systems. Siva has hands-on in architecture, design, and implementation of scalable systems using Cloud, Java, Go lang, Apache Kafka, Apache Solr, Spring, Spring Boot, Lightbend reactive tech stack, APIGEE edge & on-premise and other open-source, proprietary technologies. Expertise working with and building RESTful, GraphQL APIs. He has successfully delivered multiple applications in retail, telco, and financial services domains. He manages the GitHub( where he put the source code of his work related to his blog posts.

Tagged with: , , ,
Posted in Node.js

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.



Java Code Geeks
Java Code Geeks
%d bloggers like this: