Node.js{4}


           (Image obtained from http://nodejs.org/logos/)

 Node.js was developed in 2009 by Ryan Dahl it was created to address issues with efficiency of traditional  platforms which took far too long to communicate over the network, spending magnitudes of more time processing web requests and responses than other parts of applications. “Node.js is a platform built on Chrome’s JavaScript runtime for easily building fast, scalable network applications. Node.js uses an event-driven, non-blocking I/O model that makes it lightweight and efficient, perfect for data-intensive real-time applications that run across distributed devices” (nodejs.org, 2013).

While its use has limited areas, it’s extremely efficient for uses it’s intended for, for that reason Node.js is used for a wide variety of businesses, including Ebay, LinkedIn, Microsoft, Twitter, and Yahoo! (github.com, 2013). It also is fairly easy to learn, since it is based on JavaScript, which is widely known, and also uses a new and efficient runtime, “It’s based on Google’s runtime implementation — the aptly named “V8” engine. V8 and Node are mostly implemented in C and C++, focusing on performance and low memory consumption” (Tilkob and Vinoski, 2010).

Let’s look more in depth as to why Node.js exists, and what makes it so powerful, take a look at the following graph. “The chart below makes the magnitude differences even more obvious. The L1, L2, and RAM access times are so much smaller than disk and network access that their bars don’t even appear on the graph” (Kunkle, 2012).

 

         (Image obtained from http://kunkle.org/nodejs-explained-pres/#/title)

 It’s clear just how inefficient network operations are, but what is causing such a huge disparity?

It’s waiting, in between operations your app simply waits in between events, which take time over a network, as can be seen in the following graph.

         (Image obtained from http://kunkle.org/nodejs-explained-pres/#/title)

   Those green bars that represent actual events are tiny, all the gray areas are just waiting. There have been other ways to try to work around this in the past, either by using multiple processes, or multiple threads, but waiting still takes up a huge amount of the total time. So, how does Node.js differ?

“It extracts the “I/O waiting” by using an internal thread pool or leveraging asynchronous I/O APIs of the host operating system to free your thread for processing other connections” (Kunkle, 2012).

So how does this process look visually?

 

       (Image obtained from http://kunkle.org/nodejs-explained-pres/#/title)

     In short, events will be stored in the Event Queue, each time the Event Loop comes around, it will take the top item in Event Queue, which will then be processed in the Thread Pool. The best part of this whole process is that the items only wait as long as it takes for the actual work to be down, as opposed for their next logical step to finish.

The technical details obviously can go more in depth, but hopefully now you have a basic understanding of what Node.js functions as, a server-side JavaScript platform used for real-time applications.

Let’s now look at why Node.js is becoming so popular. “Since the framework was built for the commonly used JavaScript, the barriers to entry are remarkably low, and the reasons for choosing Node to build apps — especially low-latency, real-time apps — are increasingly compelling” (O’Dell, 2011). Joyent, the company managing Node.js, and home of Ryan Dahl, its creator is working hard to make a welcoming open-source community.

It also helps break the barrier between front-end and back-end developers, since Node.js is based off of JavaScript, so client-side and server-side development become quite a bit easier. ” This means that a developer (or two developers if you use pair-programming) can work on a feature from start-to-end. This eliminates the waiting for front/back-end to finish” (Graff, 2013).

Considering it was only created in 2009, many real world applications depend on Node.js, and major companies are noticing how useful it can be.

It’s astounding speed caused to be used in a contest hosted by the U.S. Defense Advanced Research Projects Agency. For this project teams had to take shredded pieces of paper, and using whatever means possible solve more than the other groups competing. The group that won used a Node.js server that allowed them to solve every single piece of shredded paper, and win the competition for $50,000 (Geller, 2012).

Ebay has taken notice of Node.js, using it in ql.io, their new data retrieval and aggregation gateway for HTTP API’s, “Subbu Allamaraju, an Architect at eBay, explains, “Through ql.io, we want to help application developers increase engineering clock speed and improve end user experience. ql.io can reduce the number of lines of code required to call multiple HTTP APIs while simultaneously bringing down network latency and bandwidth usage in certain use cases” (joyent.com).

LinkedIn also took note of Node.js for use in overhauling their mobile app, which previously ran using Ruby on Rails, and was experiencing serious speed issues. “The app is two to 10 times faster on the client side than its predecessor, and on the server side, it’s using a fraction of the resources, thanks to a switch from Ruby on Rails to Node.js” (O’Dell, 2011).

Another company that noticed Node.js’ usefulness is Yahoo!, who in 2011 announced their project Mojito, which allows JavaScript applications to run on both browser and server sides, requiring developers to have to do less work. Manhattan, the server side portion of Mojito uses Noded.js, ” Manhattan extends Node.JS to provide the necessary fault-isolation and fault-tolerance, scalability, availability, security and performance you’d otherwise expect from one of the largest web companies in the world” (Fernandez-Ruiz, 2011).

The most significant company to utilize Node.js is the Software giant Microsoft, which is using Node.js, along with ASP.NET and PHP in order to build sites using Windows Azure as of June 2012 (windowsazure.com). ” Node gives Azure users the first end-to-end JavaScript experience for the development of a whole new class of real-time applications” (nodejs.org).

Node.js is certainly not a solution that will improve all web browsing as we know it, it has limitations and it wasn’t built to do everything. Some downsides include the fact that it is completely event-driven, which can create issues, “on most OSs, for two applications to communicate through shared memory, shared memory segments provide no handles or file descriptors enabling the application to register for events” (Tilkov and Vinoski, 2010). Another issue pointed out is complexity if your program has to deal with other applications in different languages, “the sheer complexity of writing applications in certain programming languages to deal with events and asynchronous I/O. This is because different events require different actions in different contexts” (Tilkov and Vinoski, 2010).

In conclusion, Node.js is certainly a niche creation, but its usefulness in those areas it works in is amazing, by being able to go to a purely asynchronous system, it’s able to drastically increase performance in applications by lowering the amount of time spent waiting in I/O. It’s popularity is growing explosively, and major companies have quickly taken note, in only 4 years, it went from a new technology, to something that could go so far as to completely overhaul the mobile service for a major company like LinkedIn, and be picked up as a standard in Microsoft’s Windows Azure. With time the community, and total amount of experience surrounding Node.js will grow greatly and become a dependable technology for future companies to use.

 

References

eBay chooses Node.js as the runtime stack in ql.io: a data-retrieval and aggregation gateway for HTTP APIs – Blog – Joyent. (2011, November). Retrieved April 17, 2013, from http://joyent.com/blog/ebay-chooses-node-js-as-the-runtime-stack-in-ql-io-a-data-retrieval-and-aggregation-gateway-for-http-apis

Fernandez-Ruiz, B. (2011, November). Yahoo! Announces Cocktails – Shaken, Not Stirred | nineydn – Yahoo! Retrieved April 17, 2013, from http://developer.yahoo.com/blogs/ydn/yahoo-announces-cocktails-shaken-not-stirred-51439.html

Geller, T. (2012). DARPA Shredder Challenge Solved | August 2012 | Communications of the ACM. Retrieved April 17, 2013, from http://0-cacm.acm.org.opac.library.csupomona.edu/magazines/2012/8/153812-darpa-shredder-challenge-solved/fulltext

Graff, P. (2013, January). Why I use Node.js? | Petter’s Random Thoughts on Software. Retrieved April 17, 2013, from http://pettergraff.blogspot.com/2013/01/why-node.html

Kunkle, J. (2012a, April). Node.js Basics Explained. NearInfinity. Retrieved April 17, 2013, from http://kunkle.org/nodejs-explained-pres/#/title

Kunkle, J. (2012b, April). Node.js Explained. Retrieved April 17, 2013, from http://kunkle.org/nodejs-explained-pres/#/multi-platform

node.js. (2013). Retrieved April 17, 2013, from http://nodejs.org/

Node.js – Develop. (2013). Retrieved April 17, 2013, from http://www.windowsazure.com/en-us/develop/nodejs/

O’Dell, J. (2011a, March). Why Everyone Is Talking About Node. Retrieved April 17, 2013, from http://mashable.com/2011/03/09/node-js/

O’Dell, J. (2011b, August). Exclusive: How LinkedIn used Node.js and HTML5 to build a better, faster app | VentureBeat. Retrieved April 17, 2013, from http://venturebeat.com/2011/08/16/linkedin-node/

Projects, Applications, and Companies Using Node · joyent/node Wiki · GitHub. (2013). Retrieved April 17, 2013, from https://github.com/joyent/node/wiki/Projects,-Applications,-and-Companies-Using-Node

Tilkov, S., & Vinoski, S. (2010, December). Node.js: Using JavaSCript to Build High-Performance Network Programs. IEEEExplore. Retrieved April 17, 2013, from http://0-ieeexplore.ieee.org.opac.library.csupomona.edu/stamp/stamp.jsp?tp=&arnumber=5617064