NODE.JS SERVER SIDE JAVASCRIPT. Introduc)on Node.js

Similar documents
Module 6 Node.js and Socket.IO

Web Application Development

Lecture 18. WebSocket

NodeJS and JavaScripteverywhere

Microservices with Node.js

What is Node.js? Tim Davis Director, The Turtle Partnership Ltd

We are assuming you have node installed!

Java vs JavaScript. For Enterprise Web Applications. Chris Bailey IBM Runtime Technologies IBM Corporation

Backend Development. SWE 432, Fall 2017 Design and Implementation of Software for the Web

Western Michigan University

Backend Development. SWE 432, Fall Web Application Development

Motivation. Threads. Multithreaded Server Architecture. Thread of execution. Chapter 4

Lecture 10(-ish) Web [Application] Frameworks

Intel Do-It-Yourself Challenge Lab 5: Controlling Galileo from a webpage Nicolas Vailliet

Real-time node.js: Instrumentation, Visualization & Debugging. Bryan Cantrill SVP,

NODE.JS MOCK TEST NODE.JS MOCK TEST I

Che-Wei Chang Department of Computer Science and Information Engineering, Chang Gung University

Node.js. Node.js Overview. CS144: Web Applications

JS Event Loop, Promises, Async Await etc. Slava Kim

OWASP Switzerland. October 22th 2013

SSC - Web applications and development Introduction and Java Servlet (I)

END-TO-END JAVASCRIPT WEB APPS

CHAPTER 3 - PROCESS CONCEPT

CSC443: Web Programming 2

Introduction to RPC, Apache Thrift Workshop. Tomasz Powchowicz

CS 498RK FALL RESTFUL APIs

Chapter 4: Threads. Operating System Concepts 9 th Edition

Chapter 4: Threads. Chapter 4: Threads

Chapter 4: Threads. Operating System Concepts. Silberschatz, Galvin and Gagne

Node.js Paradigms and Benchmarks

Chapter 4: Threads. Overview Multithreading Models Thread Libraries Threading Issues Operating System Examples Windows XP Threads Linux Threads

node.js A quick tour (v4)

But before understanding the Selenium WebDriver concept, we need to know about the Selenium first.

Automated UI tests for Mobile Apps. Sedina Oruc

OPERATING SYSTEM. Chapter 4: Threads

Chapter 4: Threads. Operating System Concepts with Java 8 th Edition

CSE 4/521 Introduction to Operating Systems

CS420: Operating Systems

Chapter 4: Threads. Operating System Concepts 9 th Edition

CSCI-1680 Network Programming II. Rodrigo Fonseca

Chapter 4: Multi-Threaded Programming

Chapter 4: Threads. Chapter 4: Threads

Chapter 4: Threads. Chapter 4: Threads. Overview Multicore Programming Multithreading Models Thread Libraries Implicit Threading Threading Issues

CSE Opera,ng System Principles

Tools. SWE 432, Fall Design and Implementation of Software for the Web

Persistence. SWE 432, Fall 2017 Design and Implementation of Software for the Web

Chapter 4: Multithreaded Programming

Corey Clark PhD Daniel Montgomery

Performance Case Study

Interoperation of tasks

Kaazing Gateway: An Open Source

Comet and WebSocket Web Applications How to Scale Server-Side Event-Driven Scenarios

NoSQL & Firebase. SWE 432, Fall Web Application Development

Chris Schalk Ryan Boyd

Web Robots Platform. Web Robots Chrome Extension. Web Robots Portal. Web Robots Cloud

CS307: Operating Systems

Questions from last time

Outline. Threads. Single and Multithreaded Processes. Benefits of Threads. Eike Ritter 1. Modified: October 16, 2012

Smashing Node.JS: JavaScript Everywhere

Homework 8: Ajax, JSON and Responsive Design Travel and Entertainment Search (Bootstrap/Angular/AJAX/JSON/jQuery /Cloud Exercise)

A Scalable Event Dispatching Library for Linux Network Servers

20480C: Programming in HTML5 with JavaScript and CSS3. Course Code: 20480C; Duration: 5 days; Instructor-led. JavaScript code.

CS 450 Operating System Week 4 Lecture Notes

Web Mechanisms. Draft: 2/23/13 6:54 PM 2013 Christopher Vickery

Cookies, sessions and authentication

Human-Computer Interaction Design

Chapter 4: Multithreaded Programming

Improve Web Application Performance with Zend Platform

CSc 337 LECTURE 16: WRITING YOUR OWN WEB SERVICE

Send me up to 5 good questions in your opinion, I ll use top ones Via direct message at slack. Can be a group effort. Try to add some explanation.

Distributed Systems Principles and Paradigms

Santiago Documentation

Process Characteristics

delegator Documentation

Web Architecture AN OVERVIEW

Threads. What is a thread? Motivation. Single and Multithreaded Processes. Benefits

Persistence & State. SWE 432, Fall 2016 Design and Implementation of Software for the Web

Chapter 8: I/O functions & socket options

ESS Outline (cont.) Live demo: Staff registration configuration Personnel Info screen customization Employee Groups Absence Tracking configuration Dis

Chapter 4: Multithreaded

Chapter 4: Threads. Operating System Concepts 9 th Edit9on

I.-C. Lin, Assistant Professor. Textbook: Operating System Concepts 8ed CHAPTER 4: MULTITHREADED PROGRAMMING

Agenda Process Concept Process Scheduling Operations on Processes Interprocess Communication 3.2

Web Client And Server

Chapter 4: Threads. Overview Multithreading Models Threading Issues Pthreads Windows XP Threads Linux Threads Java Threads. Operating System Concepts

Hands-on Lab Session 9011 Working with Node.js Apps in IBM Bluemix. Pam Geiger, Bluemix Enablement

Chapter 2. Operating-System Structures

WebApp development. Outline. Web app structure. HTML basics. 1. Fundamentals of a web app / website. Tiberiu Vilcu

Introduction to HTTP. Jonathan Sillito

CPSC 341 OS & Networks. Introduction. Dr. Yingwu Zhu

Notes. Submit homework on Blackboard The first homework deadline is the end of Sunday, Feb 11 th. Final slides have 'Spring 2018' in chapter title

The Go Programming Language. Frank Roberts

SQS, SWF, and SNS 7/24/17. References. Amazon Simple Queue Service(SQS)

4. Concurrency via Threads

Introduction to Asynchronous Programming Fall 2014

User Interaction: jquery

AMT use case: Upipe + Chrome. Christophe Massiot (EBU multicast 2014)

殷亚凤. Processes. Distributed Systems [3]

EI 338: Computer Systems Engineering (Operating Systems & Computer Architecture)

Data Communication & Computer Networks MCQ S

Transcription:

NODE.JS SERVER SIDE JAVASCRIPT Introduc)on Node.js Node.js was created by Ryan Dahl starting in 2009. For more information visit: http://www.nodejs.org 1

What about Node.js? 1. JavaScript used in client-side but node.js puts the JavaScript on server-side thus making communication between client and server will happen in same language 2. Servers are normally thread based but Node.JS is Event based. Node.JS serves each request in a Evented loop that can able to handle simultaneous requests. 3. Node.JS programs are executed by V8 Javascript engine the same used by Google chrome browser HOW DOES IT DIFFER? From Node.js white paper: "Node is similar in design to and influenced by systems like Ruby's event machine or Python's twisted. Node takes the event model a bit further it presents the event loop as a language construct instead of as a library." 2

WHAT CAN YOU DO WITH NODE? " It is a command line tool. You download a tarball, compile and install the source. " It lets you Layered on top of the TCP library is a HTTP and HTTPS client/ server. " Node provides a JavaScript API to access the network and file system. WHAT CAN T DO WITH NODE? " Node is a platform for writing JavaScript applications outside web browsers. This is not the JavaScript we are familiar with in web browsers. There is no DOM built into Node, nor any other browser capability. " Node can t run on GUI, but run on terminal 3

INTERMEZZO: EVENT- BASE PROGRAMMING Event- based programming " Code is executed upon ac6va6on of events o Events = type en66es o Events are generated by external ac6ons (e.g. mouse click) " Procedural (or func6onal) programming requires explicit calls following the control flow 4

Publish- subscribe " Publishers public structured events to an event service " Subscribers express interest in par6cular events through subscrip6ons " Match: subscrip6ons against published events o Delivery of event no6fica6ons to subscribers Applica6ons " Financial Informa6on Systems " Live feed (real 6me data) " Ubiquitous compu6ng (the internet of things) " Monitoring applica6ons 5

" Heterogeneity Advantages o Interoperability is made easier " Asynchronicity o Publishers DO NOT have to synchronize with subscribers when sending events THREADS VS EVENT-DRIVEN Threads Lock application / request with listener-workers threads Using incoming-request model multithreaded server might block the request which might involve multiple events Using context switching Using multithreading environments where listener and workers threads are used frequently to take an incomingrequest lock Asynchronous Event-driven only one thread, which repeatedly fetches an event Using queue and then processes it manually saves state and then goes on to process the next event no contention and no context switches Using asynchronous I/O facilities (callbacks, not poll/ select or O_NONBLOCK) environments 6

Why node.js use eventbased? In a normal process cycle the webserver while processing the request will have to wait for the IO operations and thus blocking the next request to be processed. Node.JS process each request as events, The server doesn t wait for the IO operation to complete while it can handle other request at the same time. When the IO operation of first request is completed it will callback the server to complete the request. Standard web programming Requires multiple execution stacks 7

Func6on Call- Back SYSTEM REQUIREMENTS " Node runs best on the POSIX-like operating systems. These are the various UNIX derivatives (Solaris, and so on) or work a likes (Linux, Mac OS X, and so on). " While Windows is not POSIX compatible, Node can be built on it either using POSIX compatibility environments (in Node 0.4x and earlier). 8

Node.js VS Apache Platform Number of request per second PHP ( via Apache) 3187,27 Node.js 5569,30 A web server var http = require('http'); http.createserver(function (req, res) { res.writehead(200, {'Content-Type': 'text/plain'}); res.end('hello World\n'); }).listen(1337, '127.0.0.1'); console.log('server running at http://127.0.0.1:1337/'); The code first loads the HTTP library. It then creates a new server, and sets a callback function that will be called whenever a browser connects to the server. The server is then set to listen to incoming connections at 127.0.0.1:1337 using the listen command 9

issues Problems: The HTTP library is very low level. It allows you to operate directly on the HTTP request (req) and response objects (res) but it doesn t give you any higher-level abstrations that would help you build a web application. Some drawbacks. You only get to specify a single callback function. You have to retrieve the URL from the req parameter and match it with your list of available URLs manually. You need to set response headers manually. WEB Frameworks var express = require("express"); var app = express(); app.get("/", function(req, res) { res.send("hello world!"); res.end(); }).listen(1337); console.log('server running at http://127.0.0.1:1337/'); 10

More info " http://devlup.com/javascript/node-jsserver-side-javascript/2198/ " http://nodejs.org " http://net.tutsplus.com/tutorials/ javascript-ajax/this-time-youll-learnnode-js/ 11