• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content

Loading…

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

Like this presentation? Why not share!

Intro to Node

on

  • 7,704 views

Node.JS is a popular server-side JavaScript framework for handling real-time and distributed data processing. In this session you'll learn what Node.JS is, how it works under the hood, and what ...

Node.JS is a popular server-side JavaScript framework for handling real-time and distributed data processing. In this session you'll learn what Node.JS is, how it works under the hood, and what scenarios it's useful for. You'll also learn how to deploy it to Windows Azure and manage it inside of IIS 7.

Statistics

Views

Total Views
7,704
Views on SlideShare
4,055
Embed Views
3,649

Actions

Likes
2
Downloads
38
Comments
0

7 Embeds 3,649

http://www.aaronstannard.com 3638
http://207.46.192.232 4
http://translate.googleusercontent.com 2
http://www.linkedin.com 2
http://localhost 1
http://webcache.googleusercontent.com 1
http://www.slashdocs.com 1
More...

Accessibility

Categories

Upload Details

Uploaded via as Microsoft PowerPoint

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment
  • Designed for Data-Intensive & Real-Time Web Applications
  • Server-Side (!!) JavaScriptBuilt on top of the Chrome V8 EngineDesigned for data-intensive & real-time web applicationsEverything is asynchronous
  • Scenarios:Large request volume, low response sizeMultiplayer gamesSocial / real-time applicationsPub/SubUses a language universal to all web developersAllows developers with no prior back-end experience to leverage their skills for real applications
  • Callbacks and the Programming ModelClosuresFunctions as ObjectsDesign Patterns
  • HTML5-based IDEFree to use$12/mo for private projectsDeploys to Windows AzureHides ~90% of the configuration stuff

Intro to Node Intro to Node Presentation Transcript

  • Intro to Node.JS By Aaron StannardStartup Developer Evangelist, Microsoft Corporation
  • Examples from Today’s Talkhttps://github.com/Aaronontheweb/introtonode
  • Meet Nodevar http = require(http);//Node function called each time a new HTTP request arrivesfunction onRequest(req, res){ res.writeHead(200, {Content-Type:text/plain}); res.end(Hello + req.connection.remoteAddress + !); /* Write the IP addresses of our connecting client to console */ console.log(Incoming connection from + req.connection.remoteAddress);}//Listen for connections on the port provided by the host processvar server = http.createServer(onRequest).listen(process.env.PORT);
  • What Is Node?• Server Side JavaScript• Asynchronous Web Framework• Evented I/O Model
  • What Is Node? = + + Network I/O Libraries
  • What Makes Node Special?• Uses the familiar JavaScript programming model to enable server-side development• Buries the pain of working with async / parallel programming• No Blocking I/O• Can handle large concurrent loads more easily than other technologies• Not a silver bullet
  • Why NodeJavaScript is ubiquitous
  • Why NodeTraditional Platforms Node• Things you need for • Things you need for concurrent web concurrent web programming: programming: – Locks – Callbacks + Enclosures – Threads / Thread Pools – Thread Management – Inter-Thread Communication Which looks – Callbacks + Enclosures + Sync to Blocking Calls simpler?
  • Good Node ScenariosBehavior Application• High request volume, low • Online games, message response-sizes passing services• Pub / Sub • Social networks, content- syndication services• Real-time applications • Chat, real-time games
  • Bad Node ScenariosBehavior Application• Large HTTP response sizes • Static file servers, reporting tools• CRUD • Blogs, CMS• Transaction-heavy systems • E-Commerce
  • Node Concepts• What Do Node Projects Look Like?• Event Loop & Workers• HTTP as a First Class Citizen• Callbacks and Functions as Objects• Modules & Packages
  • Structure of a Node Project/projectroot/ package.json Tells Node and NPM what packages are required readme.txt web/ Root of your actual application server.js The main entry point for your application views/ index.html models/ post.js User-defined module for handling persistence helpers/ timestamp.js User-defined module for other stuff test/ Directory for unit tests route-test.js post-test.js node_modules/ Output directory for all NPM installationsC:[projectroot]> node web/server.jsNode server listenening on port 3000 in development mode
  • Event Loop + Workers
  • HTTP• HTTP is a first class citizen• Request Object – Holds properties about the client – Holds session state – Passes client-data to request handlers• Response Object – Holds the HTTP response stream – Can be written in chunks
  • Callbacks and Functions as Objects// HTTP GET /app/listexports.listapps = function(req, res){ var pageTitle = req.session.userName + "s Apps"; appProvider.getAppsForUser(req.session.userName, function(error, userApps){ if(error){ console.log(error.message); return res.redirect(/); } res.render(list_apps, {locals:{title: pageTitle, apps:userApps}}) });}
  • Modules & Packages• Including a built-in module var http = require(http);• Including your own module [timestamp.js] exports.currentTime = function(){…} [server.js] var timestamp = require(‘./helpers/timestamp); [server.js] console.log(timestamp.currentTime());• Node Package Manager (NPM) [Commandline] C:> npm install express [server.js] var express = require(‘express’);
  • Microsoft & Node =>Microsoft wants Windows Azure to be an optionfor developers regardless of stack
  • Node on Windows Azure• IISNode• Windows Azure Node PowerShell Cmdlets• Windows Azure Node SDK• Cloud9 IDE
  • IISNode• Hosts Node applications in IIS as native modules• Automatically manages life-cycle of node.exe• Can load-balance multiple node.exe processes
  • Azure / Node Powershell Cmdlets• Create new Azure Services• Add Node Web and Worker Roles• Deploy to Azure Emulator• Import Publish Settings• Deploy to Azure (Production / Staging)• Source @ Github
  • Windows Azure SDK• Loads Storage Settings from Web.config• Azure Tables• Azure Blobs• Azure Queues[console] C:> npm install azureSource @ Github
  • Cloud9 IDE• Browser-based IDE• Deploys to Windows Azure• Only way to deploy without Windows Vista / 7
  • Popular Node Frameworks and Tools• Express (MVC)• Connect• Socket.IO• Unit Testing: – Assert (built-in) – Nodeunit
  • Further Reference• NodeBeginner.org - Used this to teach myself Node when I was first getting started.• NodeJS.org - Official Node Homepage• Github.com/WindowsAzure – Azure bits
  • About Me• Aaron Stannard – Twitter: @Aaronontheweb – Github: @Aaronontheweb – Blog: http://www.aaronstannard.com/