Introduction to NodeJS and Its Request Processing Model

Node.js

           In this article we will see 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 non blocking I/O, that provides light weight environment. As oppose 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 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 in ideal state. For example, the request R1 is a non blocking 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 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 NodeJS running environment with examples. Till then, Happy Learning!!!

Advertisements

I am Siva Prasad Rao Janapati. Working as a software developer. Has hands on experience on ATG Commerce(DAS/DPS/DCS), Mozu commerce, Broadleaf Commerce, Java, JEE, Spring, Play, JPA, Hibernate, Velocity, JMS, Jboss, Weblogic,Tomcat, Jetty, Apache, Apache Solr, Spring Batch, JQuery, NodeJS, SOAP, REST, MySQL, Oracle, Mongo DB, Memcached, HazelCast, Git, SVN, CVS, Ant, Maven, Gradle, Amazon Web services, Rackspace, Quartz, JMeter, Junit, Open NLP, Facebook Graph,Twitter4J, YouTube Gdata, Bazzarvoice,Yotpo, 4-Tell, Alatest, Shopzilla, Linkshare. I have hands on experience on open sources and commercial technologies.

Tagged with: , , ,
Posted in Node.js

Leave a Reply

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

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s

DZone

DZone MVB

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