Node.js

Let’s know about a leader in event-driven architecture – Node.js. This is an open source and cross-platform runtime environment built using JavaScript for server-side script execution. Javascript was historically used for script execution on the client side (i.e. browser). However, this environment allows developers to use the same language on both sides that server side as well as client side.

Why is Node.js so popular?

Node.js gained popularity because of the ease of doing simple tasks and the scale that this environment can provide. It implements the event-driven architecture and async I/O. That means, whenever a client requests data, an event is added to the event queue. An Event loop constantly picks up the events in the queue. If any request can be responded to, without any blocking operations such as reading data from file system or database, it is responded immediately. If the operation is time-consuming as in case of DB operation, the event is handed off to the internally maintained thread pool and a call back is registered for this event. While the thread is executing the code in the backend, the main thread is free to process next request. This increases the throughput of Node.js server tremendously. When the DB operation is completed, the response is passed on back to the client through the callback mechanism.

Node.js model
Node.js representation. Source: https://strongloop.com/strongblog/node-js-is-faster-than-java/

Since there are already quite a few articles available on this subject, I am going to list them here for your ready reference:

 

What are the common use cases for Node.js?

Whenever you are intending to have a constant connection between server and client, Node js becomes one of the candidates. Typical examples are – a chat server, online game, Streaming etc.

Some trivia about Node.js

  • Created by Ryan Dahl in 2009
  • Uses V8 Javascript engine by Google (which is also used in Google Chrome)
  • Cross-platform – runs on Linux as well as Windows.
  • Outperforms Apache + PHP and rivals the performance with Nginx.

Related Links:

Related Keywords:

Ruby On Rails, Django, Apache, Nginx, Event Driven Architecture (EDA), Software Architecture, Non-blocking I/O, Async I/O

4 Replies to “Node.js”

Leave a Reply

Your email address will not be published.

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