NodeJs

nodejs-logo

Introduction

Node.js is a software platform for scalable server-side and networking applications. Node.js applications are written in JavaScript, and can be run within the Node.js runtime on Windows, Mac OS X and Linux with no changes.

Node.js applications are designed to maximize throughput and efficiency, using non-blocking I/O and asynchronous events. Node.js applications run single-threaded, although Node.js uses multiple threads for file and network events. Node.js is commonly used for real time applications due to its asynchronous nature.

Node.js internally uses the Google V8 JavaScript engine to execute code, and a large percentage of the basic modules are written in JavaScript. Node.js contains a built-in asynchronous i/o library for file, socket and HTTP communication. The HTTP and socket support allows Node.js to act as a web server without additional web server software such as Apache.

nodejs_architecture

Adoption as a server-side platform

Node.js is gaining adoption as a server-side platform and is used by Groupon, SAP, LinkedIn, Microsoft, Yahoo!, Walmart, Rakuten and PayPal.

Comparison of Node.js App Vs Java app

Source :- https://www.paypal-engineering.com/2013/11/22/node-js-at-paypal/

Node.Js version of the app perform better than Java version of the app.Here are the observation did by Paypal comparing the Node.js app Vs Java app :-

  • Built almost twice as fast with fewer people
  • Written in 33% fewer lines of code
  • Constructed with 40% fewer files
  • Double the requests per second vs. the Java application
  • 35% decrease in the average response time

Java Script on the Server

Java Script is the world most popular language.Some of the notable firsts were Google Maps and Gmail but today there are a host of web applications from Twitter to Facebook to Github.Because Node use java script on the server side there are other benefits :-

  1. Developers can write web applications in one language, which helps by :-
    • Reducing the “context” switch between client and server development
    • allowing for code sharing between client and server (e.g. reusing the same
      code for form validation or game logic)
  2. JSON is a very popular data interchange format today and it is native JavaScript.
  3. JavaScript is the language used in various NoSQL databases (e.g.CouchDB/MongoDB) so interfacing with them is a natural fit (e.g.MongoDB shell and query language is JS, CouchDB map/reduce is JS).
  4. Node uses one virtual machine (V8) that keeps up with the ECMAScript standard. In other words, you don’t have to wait for all the browsers to catch up to use new JavaScript language features in Node.

Type of Application Node.Js is designed

Node.js is designed for DIRTy(Data Intensive Real Time Applications) applications.
It allows a server to hold open a number of connections while handling many requests and keeping a small memory footprint. It is designed to be responsive like the browser.
Many web applications now provide information virtually instantly, implementing things like: online
whiteboard collaboration, realtime pinpointing of approaching public transit buses, and multiplayer games.
Node is good at this and not just for web, but also other I/O heavy applications.