Node.js - What is Node.js? -

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

Tornado Web and MongoDB An Introduction to AsyncMongo MongoBoston John C. Zablocki Development Manager, HealthcareSource Organizer, Beantown.
Intel Do-It-Yourself Challenge node.js
Internet of Things with Intel Edison Web controller
The GridBee Web Computing Framework Attila Szarvas BME IK 2012.
By: Craig Hecock.  A JavaScript runtime environment running Google Chrome’s V8 engine ◦ a.k.a. a server-side solution for JS ◦ Compiles JS, making it.
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.
Jerry Neal. Agenda ➢ About Node ➢ Modules ➢ Node Architecture ➢ NPM ➢ FAQ ➢ Other Awesome Modules! get ready to node, this session is hands on!
Flash: An efficient and portable Web server Authors: Vivek S. Pai, Peter Druschel, Willy Zwaenepoel Presented at the Usenix Technical Conference, June.
ASP.Net, web services--- asynchronous and synchronous and AJAX By Thakur Rashmi Singh.
Cloud Computing Lecture #7 Introduction to Ajax Jimmy Lin The iSchool University of Maryland Wednesday, October 15, 2008 This work is licensed under a.
Quick Tour of the Web Technologies: The BIG picture LECTURE A bird’s eye view of the different web technologies that we shall explore and study.
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.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
Ole Erecius Tirsdag den 9. juni Programming is always at The EDGE !!!
Philly.NET Hands-on Labs JAVASCRIPT SERIES. July 9: JavaScript Syntax Visual Studio ◦Projects ◦Editors ◦Debugging ◦Script blocks ◦Minification and bundling.
Paradigms & Benchmarks Ryan McCune CSE Final Presentation 11/3/11 Notre Dame Computer Science 1.
Putting What We Learned Into Context – WSGI and Web Frameworks A290/A590, Fall /16/2014.
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.
SE-2840 Dr. Mark L. Hornick1 NodeJS Server-side JavaScript.
Web Architecture Introduction
Chat Room App Logan Linn Network Application Design Fall 2010.
Page 1 Node.js - What? EMEA PUG Challenge, November 2015, Copenhagen 6-Nov-15 Node.js - What?
Web Technologies Lecture 7 Synchronous vs. asynchronous.
 Web pages originally static  Page is delivered exactly as stored on server  Same information displayed for all users, from all contexts  Dynamic.
Web Server Content What is web server Web Server working concept ◦ Static document ◦ Dynamic document ◦ Client side Processing Easy.
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.
Stacey Mulcahy | Technical Evangelist Rami Sayar | Technical Evangelist.
IS2803 Developing Multimedia Applications for Business (Part 2) Lecture 2: Introduction to IS2803 Rob Gleasure
1 Why Threads are a Bad Idea (for most purposes) based on a presentation by John Ousterhout Sun Microsystems Laboratories Threads!
Node.JS introduction. What is Node.JS? v8 JavaScript runtime Event driven Non-blocking standard libraries Most APIs speak streams Provides a package manager.
Learn Nodejs by Building 10 projects. What is Nodejs  An Open source, Cross platform, Event Based and Non-blocking framework used to develop server side.
Introduction to Node.js® Jitendra Kumar Patel Saturday, January 31, 2015.
NodeJS and MEAN cs6320.
Top 8 Best Programming Languages To Learn
Node.Js Server Side Javascript
Angular 4 + TypeScript Getting Started
Threads vs. Events SEDA – An Event Model 5204 – Operating Systems.
The Server-side JavaScript
CSE 775 – Distributed Objects Submitted by: Arpit Kothari
NodeJS and MEAN Prof. L. Grewe.
3 Things Everyone Knows About Node JS That You Don't
AJAX.
Node.js talking to PROGRESS
Node.Js Server Side Javascript
2017, Fall Pusan National University Ki-Joune Li
Parallel Programming in Contemporary Programming Languages (Part 2)
Distributed Systems - Comp 655
NodeJS coding basics L. Grewe.
12 Asynchronous Programming
CSE 154 Lecture 22: AJAX.
AJAX Robin Burke ECT 360.
Nathan Totten Technical Evangelist Windows Azure
Web Programming Language
INTRODUCTION TO By Stepan Vardanyan.
Week 01 Node.js Week 01
Lecture 11: Node.JS February 16, 2018 Open twitter page, sphere-e page
Lecture 12: The Fetch Api and AJAx
Lecture 14: JSON and Web SERVICES
Week 02 Node.js Week 02
Introduction.
Client Server Architecture and Data Persistence Options
Blazor A new framework for browser-based .NET apps Ryan Nowak
Presentation transcript:

Node.js - What is Node.js? - Sep. 2014 Youn-Hee Han http://link.koreatech.ac.kr

What is Node.js? A JavaScript runtime environment running Google Chrome’s V8 engine a.k.a. a server-side solution for JS Runs over the command line Designed for high concurrency Without threads or new processes Making it really fast Never blocks, not even for I/O Created by Ryan Dahl starting in 2009 Node.js is a platform (is not a framework) Express is a framework for Node.js http://sbrich.tistory.com/395 참고

What is Node.js? Goal is to provide an easy way to build scalable network programs. It makes communication between client and server happen in same language (JavaScript) Node is a platform for writing JavaScript applications outside web browsers. There is no DOM built into Node, nor any other browser capability. Node is actually programmed in C. Because of the nature of C, Node can perform amazingly well when dealing with networking and OS system calls

Asynchronous and evented In the browser Asynchronous Ajax request using XMLHttpRequest I/O doesn’t block execution Callback function The code was not written like this I/O blocks execution until finished $.post('/resource.json', function (data) { console.log(data); }); // script execution continues var data = $.post('/resource.json'); console.log(data);

Concurrency: Event Loop Instead of threads, Node uses an event loop with a stack Alleviates overhead of context switching Event loop as a language construct instead of as a library It process each request as events E.g., HTTP server doesn’t wait for the IO operation to complete while it can handle other request at the same time. To avoid blocking, it makes use of the event driven nature of JavaScript by attaching callbacks to I/O requests

Concurrency: Event Loop An example of non-blocking I/O in the browser

Concurrency: Event Loop Thread vs. Event Loop Threads Event Loop Lock application / request with listener-workers threads only one thread, which repeatedly fetches an event Using incoming-request model Using queue and then processes it multithreaded server might block the request which might involve multiple events manually saves state and then goes on to process the next event Using context switching no contention and no context switches

Number of request per second Node.js/HTTP vs. Apache Node.js/HTTP It's fast It can handle tons of concurrent requests It's written in JavaScript (which means you can use the same code server side and client side) Platform Number of request per second PHP ( via Apache) 3187,27 Static ( via Apache ) 2966,51 Node.js 5569,30

NGNIX vs. Apache NGNIX An HTTP server useing an event loop with asynchronous I/O

DIRTy applications DIRTy application Data-intensive real-time application Node.js is suitable for DIRTy application Node.js includes a core set of modules for many types of network and file I/O. Building blocks for I/O-based applications HTTP, HTTPS, filesystem (POSIX), UDP, and NET (TCP). The core is intentionally small, low-level, and uncomplicated. Third-party modules build upon these blocks to offer greater abstractions for common problems.

Example 1. Simple Async App. Node.js install http://nodejs.org/ REFL 101 http://thinkonweb.com/?p=423 Node.js app using filesystem (fs) module var fs = require('fs'); fs.readFile('./resource.json', function (er, data) { console.log(data); })

Example 2. Hello World HTTP Server An HTTP server simply responding to any request with “Hello World” Same server to make the request event explicit var http = require('http'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World\n'); }).listen(3000); console.log('Server running at http://localhost:3000/'); var http = require('http'); var server = http.createServer(); server.on('request', function (req, res) { res.writeHead(200, {'Content-Type': 'text/plain'}); res.end('Hello World\n'); }) server.listen(3000); console.log('Server running at http://localhost:3000/');

Example 3. Streaming data Stream is data distributed over time By bringing data in chunk by chunk, the developer handles the data as it comes in instead of waiting for it all to arrive before acting. var stream = fs.createReadStream('./resource.json') stream.on('data', function (chunk) { console.log(chunk) }) stream.on('end', function () { console.log('finished')

Example 4. HTTP Streaming An HTTP server streaming an image to a client Node.js provides these DIRTy-by-default approach across multiple platforms var http = require('http'); var fs = require('fs'); http.createServer(function (req, res) { res.writeHead(200, {'Content-Type': 'image/png'}); fs.createReadStream('./image.png').pipe(res); }).listen(3000); console.log('Server running at http://localhost:3000/');