Page 1 Node.js - What? EMEA PUG Challenge, November 2015, Copenhagen 6-Nov-15 Node.js - What?

Slides:



Advertisements
Similar presentations
Node.JS - Blurring the Line Between Client and Server var title = “ Node.JS - Blurring the Line Between Client and Server ”; $(this).attr(“title”, title);
Advertisements

N ODE.J S S ERVER S IDE J AVASCRIPT Diana Roiswati ( ) Ahmad Syafii ( ) Asri Taraqiadiyu ( )
© 2014 IBM Corporation Empowering the IBM ecosystem Introduction to Developing applications using node.js on Bluemix IBM Ecosystem Development Instructors.
“Using OpenEdge, Corticon, Rollbase and Node.js to create a dynamic, rule- and model- driven Web-UI” Mike Liewehr AKIOMA Software.
Inside the JSDO: Mobile and Web
A CHAT CLIENT-SERVER MODULE IN JAVA BY MAHTAB M HUSSAIN MAYANK MOHAN ISE 582 FALL 2003 PROJECT.
1 CS6320 – Why Servlets? L. Grewe 2 What is a Servlet? Servlets are Java programs that can be run dynamically from a Web Server Servlets are Java programs.
Understanding and Managing WebSphere V5
JavaScript Event Loop Not yo mama’s multithreaded approach. slidesha.re/ZPC2nD.
Interesting facts about node.js.  Asynchronous I/O  How do they do that?..threads (usually) What do Web Servers do?
 A JavaScript runtime environment running Google Chrome’s V8 engine ◦ a.k.a. a server-side solution for JS ◦ Compiles JS, making it really fast  Runs.
Written by Matthew Shelley for Professor Wei Shi.
Programming Network Servers Topic 6, Chapters 21, 22 Network Programming Kansas State University at Salina.
JavaScript & jQuery the missing manual Chapter 11
Philly.NET Hands-on Labs JAVASCRIPT SERIES. July 9: JavaScript Syntax Visual Studio ◦Projects ◦Editors ◦Debugging ◦Script blocks ◦Minification and bundling.
MEAN Stack c0nrad. Overview Day 1: – MEAN Stack – NodeJS Mini Cat Fact Spammer – MongoDB Cat Profiles – Express Catbook API (Facebook for cats) Day 2:
Chapter 17 - Deploying Java Applications on the Web1 Chapter 17 Deploying Java Applications on the Web.
Node.js - What is Node.js? -
DEV-5: Introduction to WebSpeed ® Stephen Ferguson Sr. Training Program Manager.
SAN FRANCISCO, CA, USA Daniele Bonetta Achille Peternier Cesare Pautasso Walter Binder
Orbited Scaling Bi-directional web applications A presentation by Michael Carter
1 Geospatial and Business Intelligence Jean-Sébastien Turcotte Executive VP San Francisco - April 2007 Streamlining web mapping applications.
NETWORK HARDWARE AND SOFTWARE MR ROSS UNIT 3 IT APPLICATIONS.
Server to Server Communication Redis as an enabler Orion Free
Zz SOCKET.IO going real time with Arnout Kazemier
Chat Room App Logan Linn Network Application Design Fall 2010.
Realtime insight in your application usage with NodeJs, ElasticSearch and Kibana Onno de Haan.
A New Object Model for WebSpeed and HTTP
Copyright © 2012 Kendall Electric, Inc. All rights reserved.
ICM – API Server & Forms Gary Ratcliffe.
ICM – API Server Gary Ratcliffe. 2 Agenda Webinar Programme API Server Overview JSON-RPC iCM API Service API Server and Forms New services under.
Esri UC 2014 | Demo Theater | Using ArcGIS Online App Logins in Node.js James Tedrick.
02 | Introduction to Express Framework Stacey Mulcahy | Technical Evangelist Rami Sayar | Technical Evangelist.
Node.Js 1. 2 Contents About Node.Js Web requirement latest trends Introduction Simple web server creation in Node.Js Dynamic Web pages Dynamic web page.
Node.JS introduction. What is Node.JS? v8 JavaScript runtime Event driven Non-blocking standard libraries Most APIs speak streams Provides a package manager.
Introduction to ASP.NET development. Background ASP released in 1996 ASP supported for a minimum 10 years from Windows 8 release ASP.Net 1.0 released.
Introduction to Node.js® Jitendra Kumar Patel Saturday, January 31, 2015.
Edsel Garcia Shelley Chase Fantastic Web Apps in 11.6 WebSpeed in the Pacific AppServer for OpenEdge.
Introduction to threads
NodeJS and MEAN cs6320.
Node.Js Server Side Javascript
The Server-side JavaScript
Netscape Application Server
Node.js Express Web Applications
CSE 775 – Distributed Objects Submitted by: Arpit Kothari
Node.js Express Web Services
NodeJS and MEAN Prof. L. Grewe.
3 Things Everyone Knows About Node JS That You Don't
Node.Js online Training at GoLogica.
Node.js talking to PROGRESS
Building real-time web apps with WebSockets using IIS, ASP.NET and WCF
Node.Js Server Side Javascript
2017, Fall Pusan National University Ki-Joune Li
12 Asynchronous Programming
Nathan Totten Technical Evangelist Windows Azure
Building responsive apps and sites with HTML5 web workers
Google App Engine Ying Zou 01/24/2016.
Web Programming Language
JavaScript & jQuery AJAX.
Module P3 Practical: Building a webapp in nodejs and
INTRODUCTION TO By Stepan Vardanyan.
Week 01 Node.js Week 01
RESTful Web Services.
CS5220 Advanced Topics in Web Programming More Node.js
Lecture 12: The Fetch Api and AJAx
Lecture 14: JSON and Web SERVICES
Introduction.
CS5220 Advanced Topics in Web Programming More Node.js
The Future is Now with ASP.NET Core 3.0
Presentation transcript:

Page 1 Node.js - What? EMEA PUG Challenge, November 2015, Copenhagen 6-Nov-15 Node.js - What?

Page 2 Agenda  Introduction  Node.js –What is it?  Browsers  Important modules  Progress Node.js 6-Nov-15 Node.js - What?

Page 3 Introduction  Robert Prediger  20 years experience in PROGRESS  15 years experience in web development  5 years experience in Node.js  6-Nov-15 Node.js - What?

Page 4 Node.js  Javascript is everywhere: –Browsers –Webservers –Databases –Mobile Devices  Adobe, Google, Apple and Microsoft are spending a huge amount of money!  JavaScript seems to be the worlds most used programming language. 6-Nov-15 Node.js - What?

Page 5 Node.js  What is Node.js –Server side Javascript –Built on Chrome V8 Engine –Event-driven, non blocking I/O model  What is it for? –Easily building fast, scalable network applications –Perfect for data-intensive real-time application that run across distributed devices 6-Nov-15 Node.js - What?

Page 6 Browser 6-Nov-15 Node.js - What?

Page 7 Browser 6-Nov-15 Node.js - What?

Page 8 Node.js  What is Node.js –Server side Javascript –Built on Chrome V8 Engine –Event-driven, non blocking I/O model  What is it for? –Easily building fast, scalable network applications –Perfect for data-intensive real-time application that run across distributed devices 6-Nov-15 Node.js - What?

Page 9 Node.js Blocking I/O  database, filesystem – disk  S3, external APIs – networking 6-Nov-15 Node.js - What?

Page 10 Node.js 6-Nov-15 Node.js - What?

Page 11 Node.js  Request (other languages, incl. Progress): 6-Nov-15 Node.js - What? Finished request Start 2nd request Green is executing thread Red is waiting on I/O

Page 12 Node.js  F-18 Hornet –Max speed of 1,190 mph  RAM  Banana slug –Max speed of mph  Hard disk 6-Nov-15 Node.js - What? Quelle:

Page 13 Node.js 6-Nov-15 Node.js - What?

Page 14 Nginx 6-Nov-15 Node.js - What? Quelle:

Page 15 Nginx 6-Nov-15 Node.js - What? Quelle:

Page 16 Node.js 6-Nov-15 Node.js - What?

Page 17 Node.js 6-Nov-15 Node.js - What? Q: How is it possible to handle parallel I/O with one thread of execution? A: There is (usually) no such thing as parallel I/O

Page 18 Node.js  Parallel I/O: how we see it 6-Nov-15 Node.js - What?

Page 19 Node.js  Parallel I/O: what actually happen at low level 6-Nov-15 Node.js - What?

Page 20 Node.js 6-Nov-15 Node.js - What? OS does a good job of abstracting sequential stream of raw data into logical streams: tcp sockets, http connections

Page 21 Node.js 6-Nov-15 Node.js - What? „everything runs in parallel except your code“ - it seems that a lot of people are confused by this phrase which tries to explain node.js asynchronous nature

Page 22 Node.js 6-Nov-15 Node.js - What? “everything” = I/O Since I/O is external to the code, I’d prefer to say “In node, code is organised to wait for as much as possible in parallel”

Page 23 Node.js 6-Nov-15 Node.js - What? We are not “running” functions in parallel. We are waiting for data “in parallel”. One World One WAIT-FOR

Page 24 Node.js  Request with WebSpeed: 6-Nov-15 Node.js - What? Finished request Start 2nd request Green is executing thread Red is waiting on I/O

Page 25 Node.js 6-Nov-15 Node.js - What?  Request with Node: Green is executing thread Red is waiting on I/O Event Loop Request

Page 26 Node.js 6-Nov-15 Node.js - What?

Page 27 Node.js Can handle thousands of concurrent connections with minimal overhead (CPU/Memory) on a single Process! 6-Nov-15 Node.js - What?

Page 28 Node.js Summary  Extremely efficient networking applications  Fast javascript runtime (V8)  Rapid growth in both, packages and community 6-Nov-15 Node.js - What?

Page 29 Module 6-Nov-15 Node.js - What?

Page 30 Modules  Number of Node.js modules exceeded !  Modules for nearly every problem: –pm2 –cluster –express –socket.io –restify –async –q (promises) –debug –winston 6-Nov-15 Node.js - What?

Page 31 PM2 is a production process manager for Node.js applications with a built-in load balancer. It allows you to keep applications alive forever, to reload them without downtime and to facilitate common system admin tasks. Node.js - What? pm2 6-Nov-15

Page 32 cluster 6-Nov-15 Node.js - What? var cluster = require('cluster'), http = require('http‘); if (cluster.isMaster) { // Fork workers. for (var i = 0; i < numCPUs; i++) { cluster.fork(); } cluster.on('exit', function(worker, code, signal) { console.log('worker ' + worker.process.pid + ' died'); }); } else { // Workers can share any TCP connection // In this case its a HTTP server http.createServer(function(req, res) { res.writeHead(200); res.end("hello world\n"); }).listen(8000); }

Page 33 express  6-Nov-15 Node.js - What? var express = require('express'), app = express(); app.configure(function(){ app.use( express.favicon() ); app.use( express.bodyParser() ); app.use( express.static( './public') ); }); app.get( '/login‘, route.get ); app.listen( 8081 );

Page 34 socket.io Protocol for having a bidirectional communication with client. 6-Nov-15 Node.js - What?

Page 35 socket.io  6-Nov-15 Node.js - What? var io = require('socket.io').listen( 80 ); io.sockets.on('connection', function (socket) { socket.emit( 'message', { text: 'Hello World' }); // broadcast message to all subscribed sockets socket.broadcast.emit("chat", { name: socket.nickname, msg: msg });

Page 36 socket.io Demo 6-Nov-15 Node.js - What?

Page 37 restify - Client  6-Nov-15 Node.js - What? var client = restify.createJsonClient({ url: ' version: '*‘ }); client.post('/foo', { hello: 'world' }, function(err, req, res, obj) { assert.ifError(err); console.log( res.statusCode, '->', res.headers ); console.log( obj ); });

Page 38 restify - Server  6-Nov-15 Node.js - What? var restify= require('restify‘), server= restify.createServer({ name: 'myapp', version: '1.0.0' }); server.use(restify.acceptParser(server.acceptable)); server.use(restify.queryParser()); server.use(restify.bodyParser()); server.get('/echo/:name', function (req, res, next ) { res.send(req.params); return next(); }); server.listen( 8080, function () { console.log('%s listening at %s', server.name, server.url); });

Page 39 async  6-Nov-15 Node.js - What? // an example using an object instead of an array async.parallel({ one: function(callback){ setTimeout(function(){ callback(null, 1); }, 200); }, two: function(callback){ setTimeout(function(){ callback(null, 2); }, 100); } }, function(err, results) { // results is now equals to: {one: 1, two: 2} } );

Page 40 debug  6-Nov-15 Node.js - What? var debug= require("debug"), log= debug("demo:socket"); function login ( name ) { log( "login", name ); client.nickname = name; }

Page 41 winston  6-Nov-15 Node.js - What? var winston = require('winston'); var logger = new (winston.Logger)( { transports: [ new (winston.transports.Console)( { level: 'warn' } ), new (winston.transports.File)( { filename: 'somefile.log', level: 'error‘ } ) ] }); logger.debug( "Will not be logged in either transport!" ); logger.transports.console.level = 'debug'; logger.transports.file.level = 'verbose'; logger.verbose("Will be logged in both transports!");

Page 42 Progress - WebSpeed  REST: Node.js -> Progress WebSpeed –pro Easy to maintain –con Overhead with HTTP Messenger 6-Nov-15 Node.js - What?

Page 43 Progress - WebSpeed 6-Nov-15 Node.js - What? {src/web/method/cgidefs.i} output-content-type("application/json":U). IF NOT WEB-CONTEXT:IS-JSON THEN DO: LOG-MANAGER:WRITE-MESSAGE( "No JSON request" ). RETURN. END. /* read json */ oParse = NEW ObjectModelParser(). jData = CAST( oParse:Parse( WEB-CONTEXT:HANDLE ), JsonObject ).

Page 44 Progress - WebSpeed 6-Nov-15 Node.js - What?... hDataSet:FILL(). jResult = NEW JsonObject(). jDataSet = NEW JsonObject(). jDataSet:READ( hDataSet ). jResult:Add( "data", jDataSet ). jResult:WriteStream( "Webstream" ).

Page 45 Progress - AppServer  REST: Node.js -> Progress AppServer –pro Webservice –con Overhead with Tomcat Deployment with ProxyGen 6-Nov-15 Node.js - What?

Page 46 Progress – node4progress  node4progress – –pro very fast Structured API –con Overhead with java engine between 6-Nov-15 Node.js - What?

Page 47 Progress – node4progress 6-Nov-15 Node.js - What? var conf = require("./config.json"); var n4p= require("node4progress")(conf); n4p.setAppsvrProc("CustomerHandler.p","",false,true); n4p.setParameter("InputPars","longchar","input","batchNum=2",""); n4p.setParameter("OutputPars","character","output","",""); n4p.setParameter("dsCustomer","dataset-handle","output","",""); n4p.setParameter("ErrMsg","character","output","",""); n4p.appProc().execute(function(err,result){ if(err){ console.log("ERROR->"+err); }else{ result=JSON.parse(result); } });

Page 48 Progress – node4progress 6-Nov-15 Node.js - What? var conf = require('config.json'), n4p = require('node4progressHttp')conf.prgs); var handler = "handlers/CustomerHandler.p", inputPars = "NumCustomersToPull=2"; n4p.callHandler( handler, inputPars, function(result){ console.log(result); });

Page 49 Progress – JSDO  JSDO – – –pro very fast Structured API –con Infrastructure (beginning with OE 11.5) 6-Nov-15 Node.js - What?

Page 50 Progress – JSDO 6-Nov-15 Node.js - What? XMLHttpRequest = require("./XMLHttpRequest.js").XMLHttpRequest; Require("./progress.js"); Require("./progress.session.js"); // get connection to progress and get catalog var session = new progress.data.Session(); session.login( conf.serviceURI, "", ""); session.addCatalog( conf.catalogURI );

Page 51 Progress – JSDO 6-Nov-15 Node.js - What? // create jsdo var jsdo = new progress.data.JSDO( { name: 'dsCustomer' } ); jsdo.subscribe( 'AfterFill', onAfterFillCustomers, this); jsdo.fill(); // fills the locally initialized jsdo from the catalog function onAfterFillCustomers( jsdo, success, request ) { var result = []; jsdo.eCustomer.foreach( function( cust ) { result.push( cust.data ); }); callback( null, result ); }

Page 52 End Questions? 6-Nov-15 Node.js - What?