Introduction to Node.JS Pragnesh Vaghela | @technologythree | technologythree.com
Problem what’s a really common thing to do in a web application? Database access, of course. Too bad database I/O is one of the slowest things a web app has to deal with data = readFromDatabase(); printData(data); doSomethingUnrelated(); asynchronous JavaScript: readFromDatabase(function(data) { printData(data); }) doSomethingUnrelated(); @ 2013 Technology Three 2
NODE.JS 1. platform built on Chrome's JavaScript runtime for easily building fast, scalable network applications 2. perfect for data-intensive real-time applications that run across distributed devices @ 2013 Technology Three 3
NODE.JS 1. server-side JavaScript framework - the same type of code that powers awesome Ajax applications like Gmail will now power its servers, too 2. driven by asynchronous design - that it doesn’t have to wait for slow file I/O or database operations to continue processing, which makes it really damn fast. It also means that it can handle millions of concurrent connections at once 3. real-time applications - you do not have to bother with low-level sockets and protocols @ 2013 Technology Three 4
Bad Use Cases 1. apps that are very heavy on CPU usage, and very light on actual I/O - video encoding software, artificial intelligence or similar CPU hungry software 2. simple CRUD / HTML apps @ 2013 Technology Three 5
Good Use Cases • JSON APIs building light-weight REST / JSON api's is something where node.js really shines. Its non-blocking I/O model combined with JavaScript make it a great choice for wrapping other data sources such as databases or web services and exposing them via a JSON interface • Single page Apps if you are planning to write an AJAX heavy single page app (think gmail), node.js is a great fit as well. The ability to process many requests / seconds with low response times, as well as sharing things like validation code between the client and server make it a great choice for modern web applications that do lots of processing on the client @ 2013 Technology Three 6
Good Use Cases • Streaming data one great example is parsing file uploads in real time, as well as building proxies between different data layers • Soft Realtime Applications easy to develop soft real time systems like twitter, chat software, sport bets or interfaces to instant messaging networks @ 2013 Technology Three 7
Example Web Server var http = require('http'); http.createServer(function (request, response) { response.writeHead(200, {'Content-Type': 'text/plain'}); response.end('Hello Worldn'); }).listen(8124); console.log('Server running at http://127.0.0.1:8124/'); To run the server, put the code into a file called example.js and execute it with the node program: > node example.js Server running at http://127.0.0.1:8124/ @ 2013 Technology Three 8
Real world Node.JS Applications @ 2013 Technology Three 9
NODE.JS in the industry 1. CBS, Linkedin use Node.js for mobile 2. Walmart’s Node-powered mobile app front-end code gets executed on the back end 3. Yahoo has released some things for Node, and supports cocktails - a Node.js platform. It also uses Node.js in the livestand infrastructure 4. Mozilla has implemented Node.js to support browser APIs which has half a billion installs 5. Pinterest uses Node as a webserver in some instances 6. Ebay hosts their HTTP API service with Node 7. HP uses Node for their WebOS initiatives @ 2013 Technology Three 10
Thank You Pragnesh Vaghela | @technologythree | technologythree.com

Introduction to Node js

  • 1.
    Introduction to Node.JS Pragnesh Vaghela | @technologythree | technologythree.com
  • 2.
    Problem what’s a reallycommon thing to do in a web application? Database access, of course. Too bad database I/O is one of the slowest things a web app has to deal with data = readFromDatabase(); printData(data); doSomethingUnrelated(); asynchronous JavaScript: readFromDatabase(function(data) { printData(data); }) doSomethingUnrelated(); @ 2013 Technology Three 2
  • 3.
    NODE.JS 1. platform builton Chrome's JavaScript runtime for easily building fast, scalable network applications 2. perfect for data-intensive real-time applications that run across distributed devices @ 2013 Technology Three 3
  • 4.
    NODE.JS 1. server-side JavaScriptframework - the same type of code that powers awesome Ajax applications like Gmail will now power its servers, too 2. driven by asynchronous design - that it doesn’t have to wait for slow file I/O or database operations to continue processing, which makes it really damn fast. It also means that it can handle millions of concurrent connections at once 3. real-time applications - you do not have to bother with low-level sockets and protocols @ 2013 Technology Three 4
  • 5.
    Bad Use Cases 1.apps that are very heavy on CPU usage, and very light on actual I/O - video encoding software, artificial intelligence or similar CPU hungry software 2. simple CRUD / HTML apps @ 2013 Technology Three 5
  • 6.
    Good Use Cases •JSON APIs building light-weight REST / JSON api's is something where node.js really shines. Its non-blocking I/O model combined with JavaScript make it a great choice for wrapping other data sources such as databases or web services and exposing them via a JSON interface • Single page Apps if you are planning to write an AJAX heavy single page app (think gmail), node.js is a great fit as well. The ability to process many requests / seconds with low response times, as well as sharing things like validation code between the client and server make it a great choice for modern web applications that do lots of processing on the client @ 2013 Technology Three 6
  • 7.
    Good Use Cases •Streaming data one great example is parsing file uploads in real time, as well as building proxies between different data layers • Soft Realtime Applications easy to develop soft real time systems like twitter, chat software, sport bets or interfaces to instant messaging networks @ 2013 Technology Three 7
  • 8.
    Example Web Server varhttp = require('http'); http.createServer(function (request, response) { response.writeHead(200, {'Content-Type': 'text/plain'}); response.end('Hello Worldn'); }).listen(8124); console.log('Server running at http://127.0.0.1:8124/'); To run the server, put the code into a file called example.js and execute it with the node program: > node example.js Server running at http://127.0.0.1:8124/ @ 2013 Technology Three 8
  • 9.
    Real world Node.JS Applications @ 2013 Technology Three 9
  • 10.
    NODE.JS in theindustry 1. CBS, Linkedin use Node.js for mobile 2. Walmart’s Node-powered mobile app front-end code gets executed on the back end 3. Yahoo has released some things for Node, and supports cocktails - a Node.js platform. It also uses Node.js in the livestand infrastructure 4. Mozilla has implemented Node.js to support browser APIs which has half a billion installs 5. Pinterest uses Node as a webserver in some instances 6. Ebay hosts their HTTP API service with Node 7. HP uses Node for their WebOS initiatives @ 2013 Technology Three 10
  • 11.
    Thank You Pragnesh Vaghela| @technologythree | technologythree.com