Node.js was created by Ryan Dahl in 2009. NPM a package manager for Node.js libraries was introduced in 2011.
Event driven programming is the core of Node.js applications. Event driven programming is a programming paradigm in which the flow of the program is determined by events. Its an application architecture in which main loop is divided into two sections i.e. event selection and event handling.
Node.js can keep many connections without dropping new incoming connections by using single threaded event based loop. Node.js can be extended using CommonJS module system.
Applications are executed from the command line with command: node <app name>.js
Traditionally web-serving required each request to create a new thread on webserver. In Node.js a callback is issued by operating system when a connection is made. Within in node.js runtime each connection is a small heap allocation. Node.js uses an event loop, instead of processes or threads, to scale to millions of connections happening at the same time. Node.js event loop doesn’t need to be called explicitly. Instead callbacks are defined and the server automatically enters the event loop at the end of call back definition. Node.js exits the event loop when there are no callbacks to be performed.
NPM is the package manager of Node.js. Using command line NPM registry developers can install code.
NodeSchool is an excellent way to learn about node.js. Below is the Node.js internal architecture.
Socket.io is a powerful Node module that brings the ability to simply manage long term connections with the clients.
Promises is a way to manage asynchronous control flow. A promise is an object that represents the result of an asynchronous function call. Promises are also called futures and deferreds in some communities. Promises have three states pending, fulfilled and rejected.
To monitor, troubleshoot and diagnose performance issues in your node.js applications Nodetime is quite handy. Nodetime reveals internals of your application and infrastructure through profiling and proactive monitoring enabling detailed analysis, fast troubleshooting, performance and capacity optimization. Node time metrics cover operating system state, garbage collection activity, application capacity, transactions and data base calls for supported libraries.