Chris Bailey Bailey. Emerging Web Application Architectures With Java and Node.js

Similar documents
Java with Node.js Powering the Next Generation of Web Applications

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

END-TO-END JAVASCRIPT WEB APPS

this presentation code is on

Microservices with Node.js

Przyspiesz tworzenie aplikacji przy pomocy Openshift Container Platform. Jarosław Stakuń Senior Solution Architect/Red Hat CEE

RED HAT'S CONTAINER STRATEGY. Lars Herrmann General Manager, RHEL, RHEV and Containers June 24, 2015

A DEVOPS STATE OF MIND WITH DOCKER AND KUBERNETES. Chris Van Tuin Chief Technologist, West

CHAPTER 1 Introduction to Computers and Java

MongoDB Web Architecture

Lecture 18. WebSocket

Chapter 1: Introduction to Computers and Java

8/23/2014. Chapter Topics. Introduction. Java History. Why Program? Java Applications and Applets. Chapter 1: Introduction to Computers and Java

Web application Architecture

CS 11 java track: lecture 1

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

INF 212 ANALYSIS OF PROG. LANGS CONCURRENCY. Instructors: Crista Lopes Copyright Instructors.

Santiago Documentation

Module 3 Web Component

Performance Case Study

Front End Programming

1. Download the JDK 6, from

Lecture 1: Overview of Java

Making Sense of your Data

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

IBM s statements regarding its plans, directions, and intent are subject to change or withdrawal without notice at IBM s sole discretion.

Who am I? Weibo:

Node.js: Asynchronous I/O for Fun and Profit. Stefan QCon London 2011

Introduction to Java

JAVA OPERATORS GENERAL

Module 6 Node.js and Socket.IO

Introduction to Java

INF5750. Introduction to JavaScript and Node.js

Making Sense of your Data BUILDING A CUSTOM MONGODB DATASOURCE FOR GRAFANA WITH VERTX

Isomorphic Kotlin. Troy

A Node.js tutorial by Manuel Kiessling

Tableau Server - 101

Lecture 2. COMP1406/1006 (the Java course) Fall M. Jason Hinek Carleton University

Introduction to Java. Nihar Ranjan Roy.

COMP519 Practical 5 JavaScript (1)

Program Fundamentals

Lecture 1 - Introduction (Class Notes)

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview

Learning objectives. The Java Environment. Java timeline (cont d) Java timeline. Understand the basic features of Java

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

Outline. 1. Load Testing 2. Frontend Tips 3. Server-side Tips

Goals. Java - An Introduction. Java is Compiled and Interpreted. Architecture Neutral & Portable. Compiled Languages. Introduction to Java

1.1 Your First Program

The Java programming environment. The Java programming environment. Java: A tiny intro. Java features

IBM API Connect: Introduction to APIs, Microservices and IBM API Connect

The API Economy in a Mobile World What are we talking about?

Ur/Web: A Simple Model for Programming the Web. Adam Chlipala MIT CSAIL POPL 2015 January 15, 2015

Introduction to Programming Using Java (98-388)

IBM Planning Analytics Workspace Local Distributed Soufiane Azizi. IBM Planning Analytics

Introduction to RPC, Apache Thrift Workshop. Tomasz Powchowicz

Space Exploration EECS /25

The Future of the Realtime Web BETTER APIS WITH GRAPHQL. Josh

API Connect. Arnauld Desprets - Technical Sale

Il Mainframe e il paradigma dell enterprise mobility. Carlo Ferrarini zsystems Hybrid Cloud

CSC 1214: Object-Oriented Programming

Atelier Java - J1. Marwan Burelle. EPITA Première Année Cycle Ingénieur.

A Generic Microservice Architecture for Environmental Data Management

Introduction to Programming (Java) 2/12

Updating web content in real time using Node.js

Algorithms and Programming I. Lecture#12 Spring 2015

CSC Web Programming. Introduction to JavaScript

Esri and MarkLogic: Location Analytics, Multi-Model Data

Review Chapters 1 to 4. Instructor: Scott Kristjanson CMPT 125/125 SFU Burnaby, Fall 2013

INFO Object-Oriented Programming

Computer Components. Software{ User Programs. Operating System. Hardware

Reactive Programming with Vert.x

Windows 8. Rainer Stropek. System Architecture. System Architecture re of Windows Store Apps. Saves the day. software architects gmbh

Preview from Notesale.co.uk Page 3 of 36

Object-oriented programming. and data-structures CS/ENGRD 2110 SUMMER 2018

JavaScript: Introduction, Types

This exam is open book. Each question is worth 3 points.

NODE.JS MOCK TEST NODE.JS MOCK TEST I

Outline. Overview. Control statements. Classes and methods. history and advantage how to: program, compile and execute 8 data types 3 types of errors

Android Online Training

MODIFYING TRADITIONAL APPLICATIONS FOR MORE COST EFFECTIVE DEPLOYMENT

AWS Lambda + nodejs Hands-On Training

JavaScript I Language Basics

COMP 110/L Lecture 13. Kyle Dewey

Putting A Spark in Web Apps

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

CS 231 Data Structures and Algorithms, Fall 2016

Future Web App Technologies

1.1 Your First Program

Web Architecture and Development

Basic Concepts. Computer Science. Programming history Algorithms Pseudo code. Computer - Science Andrew Case 2

CONCURRENT DISTRIBUTED TASK SYSTEM IN PYTHON. Created by Moritz Wundke

Getting started with Java

INTRODUCTION TO SOFTWARE SYSTEMS (COMP1110/COMP1140/COMP1510/COMP6710)

An overview of Java, Data types and variables

C and C++ I. Spring 2014 Carola Wenk

LECTURE 7. Web-Technology

Lecture 2 Callbacks, Events, and Asynchronous Programming

PROCE55 Mobile: Web API App. Web API.

Outline. Java Models for variables Types and type checking, type safety Interpretation vs. compilation. Reasoning about code. CSCI 2600 Spring

Overview. Prerequisites. Course Outline. Course Outline :: Apache Spark Development::

Transcription:

Chris Bailey IBM Emerging Web Application Architectures With Java and Node.js

STSM, IBM Runtime Development 2 @seabaylea 2015 IBM Corporation 1

The Annual Death of Java Developer trend No. 2: Java s decline as a language will accelerate

The Annual Death of Java Developer trend No. 2: Java s decline as a language will accelerate Java is in decline look at the jobs. Yes, there are more of them... doing maintenance.

The Annual Death of Java Developer trend No. 2: Java s decline as a language will accelerate Java is in decline look at the jobs. Yes, there are more of them... doing maintenance. Now look at the Node.js or Spark or MongoDB job postings. Those are about doing new development

Developer Ecosystem

Developer Ecosystem #1 JavaScript #2 Java

Developer Ecosystem Module counts over time vs #1 JavaScript #2 Java

Developer Ecosystem Module counts over time vs #1 JavaScript #2 Java #1 JavaScript #2 Java

Usage in the browser Unless it is absolutely necessary to run Java in web browsers, disable it as described below, even after updating to 7u11. This will help mitigate other Java vulnerabilities that may be discovered in the future. This and previous Java vulnerabilities have been widely targeted by attackers, and new Java vulnerabilities are likely to be discovered. To defend against this and future Java vulnerabilities, consider disabling Java in web browsers

Usage in the browser Unless it is absolutely necessary to run Java in web browsers, disable it as described below, even after updating to 7u11. This will help mitigate other Java vulnerabilities that may be discovered in the future. This and previous Java vulnerabilities have been widely targeted by attackers, and new Java vulnerabilities are likely to be discovered. To defend against this and future Java vulnerabilities, consider disabling Java in web browsers

Why JavaScript and Node.js?

Rise of Rich Web Applications

Isomorphic Development an Server-Side Rendering Reuse of code components Write One Run Anywhere Sharing of data models Less maintenance Server-side rendering Pre-Initialise UI on the server Improves first paint time Enables search indexing

Typical Java Approach to Scalable I/O One thread (or process) per connection - Each thread waits on a response - Scalability determined by the number of threads Each thread: - consumes memory - is relatively idle Concurrency determined by number of depot workers

Node.js approach to Scalable I/O One thread multiplexes for multiple requests - No waiting for a response - Handles return from I/O when notified Scalability determined by: - CPU usage - Back end responsiveness Concurrency determined by how fast the food server can work

Rapid Development var cluster = require('cluster'); var cpus = require('os').cpus().length; var http = require('http'); if (cluster.ismaster) { for (var i = 0; i < cpus; i++) { cluster.fork(); } cluster.on('death', function(worker) { console.log("worker" + worker.pid + "died"); }); } else { http.createserver(function(request, response) { response.writehead(200, {"Content-Type": "text/plain"}); response.write("hello World!\n"); response.end(); }).listen(8080); }

Rapid Development var cluster = require('cluster'); var cpus = require('os').cpus().length; var http = require('http'); if (cluster.ismaster) { for (var i = 0; i < cpus; i++) { cluster.fork(); } cluster.on('death', function(worker) { console.log("worker" + worker.pid + "died"); }); } else { http.createserver(function(request, response) { response.writehead(200, {"Content-Type": "text/plain"}); response.write("hello World!\n"); response.end(); }).listen(8080); }

Event based programming var http = require('http'); var server = http.createserver(); server.listen(8080); server.on('request', function(request, response) { response.writehead(200, {"Content-Type": "text/plain"}); response.write("hello World!\n"); response.end(); }); server.on('connection', function(socket) {}); server.on('close', function() {}); server.on('connect', function(socket) {}); server.on('upgrade', function(request, socket, head) {}); server.on('clienterror', function(exception, socket) {});

Why Java?

Compute Performance 80 70 60 50 40 30 20 10 0 Benchmarks Game Comple1on Times (lower is be+er) Regex-dna n-body reverse-comp spectral-norm mandelbrot fasta-redux binary-trees pidigits k-nucleobde fannkuch-redux fasta

Compute Performance 80 70 60 50 40 30 20 10 0 Benchmarks Game Comple1on Times (lower is be+er) Regex-dna n-body reverse-comp spectral-norm mandelbrot fasta-redux binary-trees pidigits k-nucleobde fannkuch-redux fasta

Web Application Performance 120 100 80 60 40 20 TechEmpower Performance (%age of best - higher is be0er) 0 JSON Serializa2on Single Query Data Updates More Computation More I/O

JSON Serialisation JSON serialization of a newly instantiated object Maps - Key of message - Value of Hello, World! Example response:

JSON Serialisation JSON serialization of a newly instantiated object Maps - Key of message - Value of Hello, World! Java JavaScript Example response:

Web Application Performance 120 100 80 60 40 20 TechEmpower Performance (%age of best - higher is be0er) 0 JSON Serializa2on Single Query Data Updates More Computation More I/O

Web Application Performance 120 100 80 60 40 20 TechEmpower Performance (%age of best - higher is be0er) 0 JSON Serializa2on Single Query Data Updates More Computation More I/O

Single Query Fetches single row from simple database table Row serialized as JSON Example response:

Single Query Fetches single row from simple database table Row serialized as JSON Java JavaScript Example response:

Web Application Performance 120 100 80 60 40 20 TechEmpower Performance (%age of best - higher is be0er) 0 JSON Serializa2on Single Query Data Updates More Computation More I/O

Web Application Performance 120 100 80 60 40 20 TechEmpower Performance (%age of best - higher is be0er) 0 JSON Serializa2on Single Query Data Updates More Computation More I/O

Data Updates Fetches single row from simple database table Row serialized as JSON Example response:

Data Updates Fetches single row from simple database table Row serialized as JSON JavaScript Java Example response:

Web Application Performance 120 100 80 60 40 20 TechEmpower Performance (%age of best - higher is be0er) 0 JSON Serializa2on Single Query Data Updates More Computation More I/O

Web Application Performance 120 100 80 60 40 20 TechEmpower Performance (%age of best - higher is be0er) 0 JSON Serializa2on Single Query Data Updates More Computation More I/O

Dynamic Typing in JavaScript: The + operator var add = function (a, b) { return (a + b); }

Dynamic Typing in JavaScript: The + operator var add = function (a, b) { return (a + b); } Check type of A

Dynamic Typing in JavaScript: The + operator var add = function (a, b) { return (a + b); } String Check type of A Number

Dynamic Typing in JavaScript: The + operator var add = function (a, b) { return (a + b); } String Check type of B String Check type of A Number Number

Dynamic Typing in JavaScript: The + operator var add = function (a, b) { return (a + b); } Concatenate String Check type of B String Check type of A Number Number

Dynamic Typing in JavaScript: The + operator var add = function (a, b) { return (a + b); } Concatenate String Check type of B String Check type of A Number Number Concatenate

Dynamic Typing in JavaScript: The + operator var add = function (a, b) { return (a + b); } Concatenate String Check type of B String Check type of A Number Check type of B String Number Number Concatenate

Dynamic Typing in JavaScript: The + operator var add = function (a, b) { return (a + b); } Concatenate String Check type of B String Check type of A Number Check type of B String Concatenate Number Number Concatenate

Dynamic Typing in JavaScript: The + operator var add = function (a, b) { return (a + b); } Concatenate String Check type of B String Check type of A Number Check type of B String Concatenate Number Number Concatenate Float Floating Point or Normal Normal

Dynamic Typing in JavaScript: The + operator var add = function (a, b) { return (a + b); } Concatenate String Check type of B String Check type of A Number Check type of B String Concatenate Number Number Concatenate Float Floating Point or Normal Normal Add Instruction

Dynamic Typing in JavaScript: The + operator var add = function (a, b) { return (a + b); } Concatenate String Check type of B String Check type of A Number Check type of B String Concatenate Number Number Concatenate Float Calculation Float Floating Point or Normal Normal Add Instruction

Strong Typing in Java: The + operator int add(int a, int b) { return (a + b); }

Strong Typing in Java: The + operator int add(int a, int b) { return (a + b); } Add Instruction

Strong Typing in Java: The + operator int add(int a, int b) { return (a + b); } Add Instruction Return Result

Type Safety private static void add (int a, int b){ System.out.println(a + b); } public static void main(string[] args){ int a = 5; int b = 3; var add = function (a, b) { console.log(a + b); } var a = 5; var b = 3; } add(a, b); add(a, b); > javac app.java > java app > 8 > node app.js > 8

Type Safety private static void add (int a, int b){ System.out.println(a + b); } public static void main(string[] args){ int a = 5; int b = 3; var add = function (a, b) { console.log(a + b); } var a = 5; var b = 3; } add(a, b); add(a, b); > javac app.java > java app > 8 > node app.js > 8

Type Safety private static void add (int a, int b){ System.out.println(a + b); } public static void main(string[] args){ int a = 5; int b = 3; var add = function (a, b) { console.log(a + b); } var a = 5; var b = 3; } add(a, b); add(a, b); > javac app.java > java app > 8 > node app.js > 8

Type Safety private static void add (int a, int b){ System.out.println(a + b); } public static void main(string[] args){ int a = 5; int b = 3; var add = function (a, b) { console.log(a + b); } var a = 5; var b = 3; } add(a, b); add(a, b); > javac app.java > java app > 8 > node app.js > 8

Type Safety private static void add (int a, int b){ System.out.println(a + b); } public static void main(string[] args){ int a = 5; int b = 3; var add = function (a, b) { console.log(a + b); } var a = 5; var b = 3; } add(a, b); add(a, b); > javac app.java > java app > 8 > node app.js > 8

Type Safety private static void add (int a, int b){ System.out.println(a + b); } public static void main(string[] args){ String a = new String( 5 ); int b = 3; var add = function (a, b) { console.log(a + b); } var a = 5 ; var b = 3; } add(a, b); add(a, b); > javac app.java > java app > 8 > node app.js > 8

Type Safety private static void add (int a, int b){ System.out.println(a + b); } public static void main(string[] args){ String a = new String( 5 ); int b = 3; var add = function (a, b) { console.log(a + b); } var a = 5 ; var b = 3; } add(a, b); add(a, b); > javac app.java > java app > 8 > node app.js > 8

Type Safety private static void add (int a, int b){ System.out.println(a + b); } public static void main(string[] args){ String a = new String( 5 ); int b = 3; var add = function (a, b) { console.log(a + b); } var a = 5 ; var b = 3; } add(a, b); add(a, b); > javac app.java Error: incompatible types: String cannot be converted to int add(a, b); ^ > node app.js > 8

Type Safety private static void add (int a, int b){ System.out.println(a + b); } public static void main(string[] args){ String a = new String( 5 ); int b = 3; var add = function (a, b) { console.log(a + b); } var a = 5 ; var b = 3; } add(a, b); add(a, b); > javac app.java Error: incompatible types: String cannot be converted to int add(a, b); ^ > node app.js > 53

JavaScript Calculations > 5 + 3 8 > '5' + 3 '53' > '5' 3 2 // Weak typing, implicit conversion > '5' '4' 1 // String minus String = Integer?? > '5' + + '4' 54 // Multiple +'s are ok > 'Hello' + 'World' 'HelloWorld' > 'Hello' + + 'World' 'HelloNaN' // Ok, that's expected //...but that isn't

JavaScript Calculations > 5 + 3 8 > '5' + 3 '53' > '5' 3 2 // Weak typing, implicit conversion > '5' '4' 1 // String minus String = Integer?? > '5' + + '4' 54 // Multiple +'s are ok > 'Hello' + 'World' 'HelloWorld' > 'Hello' + + 'World' 'HelloNaN' // Ok, that's expected //...but that isn't

JavaScript Calculations > 5 + 3 8 > '5' + 3 '53' > '5' 3 2 // String is converted to a number for subtraction > '5' '4' 1 // String minus String = Integer?? > '5' + + '4' 54 // Multiple +'s are ok > 'Hello' + 'World' 'HelloWorld' > 'Hello' + + 'World' 'HelloNaN' // Ok, that's expected //...but that isn't

JavaScript Calculations > 5 + 3 8 > '5' + 3 '53' > '5' 3 2 // String is converted to a number for subtraction > '5' '4' 1 // String minus String = Integer?? > '5' + + '4' 54 // Multiple +'s are ok > 'Hello' + 'World' 'HelloWorld' > 'Hello' + + 'World' 'HelloNaN' // Ok, that's expected //...but that isn't

JavaScript Calculations > 5 + 3 8 > '5' + 3 '53' > '5' 3 2 // String is converted to a number for subtraction > '5' '4' 1 // Both Strings converted to number for subtraction > '5' + + '4' 54 // Multiple +'s are ok > 'Hello' + 'World' 'HelloWorld' > 'Hello' + + 'World' 'HelloNaN' // Ok, that's expected //...but that isn't

JavaScript Calculations > 5 + 3 8 > '5' + 3 '53' > '5' 3 2 // String is converted to a number for subtraction > '5' '4' 1 // Both Strings converted to number for subtraction > '5' + + '4' 54 // Multiple +'s are ok > 'Hello' + 'World' 'HelloWorld' > 'Hello' + + 'World' 'HelloNaN' // Ok, that's expected //...but that isn't

JavaScript Calculations > 5 + 3 8 > '5' + 3 '53' > '5' 3 2 // String is converted to a number for subtraction > '5' '4' 1 // Both Strings converted to number for subtraction > '5' + + '4' 54 // Multiple +'s are ok > 'Hello' + 'World' 'HelloWorld' > 'Hello' + + 'World' 'HelloNaN' // Ok, that's expected //...but that isn't

JavaScript Calculations > 5 + 3 8 > '5' + 3 '53' > '5' 3 2 // String is converted to a number for subtraction > '5' '4' 1 // Both Strings converted to number for subtraction > '5' + + '4' 54 // Multiple +'s are ok > 'Hello' + 'World' 'HelloWorld' > 'Hello' + + 'World' 'HelloNaN' // Ok, that's expected //...but that isn't

JavaScript Calculations > 5 + 3 8 > '5' + 3 '53' > '5' 3 2 // String is converted to a number for subtraction > '5' '4' 1 // Both Strings converted to number for subtraction > '5' + + '4' 54 // Multiple +'s are ok > 'Hello' + 'World' 'HelloWorld' > 'Hello' + + 'World' 'HelloNaN' // Ok, that's expected //...but that isn't

JavaScript Calculations > 5 + 3 8 > '5' + 3 '53' > '5' 3 2 // String is converted to a number for subtraction > '5' '4' 1 // Both Strings converted to number for subtraction > '5' + + '4' 54 // Multiple +'s are ok > 'Hello' + 'World' 'HelloWorld' > 'Hello' + + 'World' 'HelloNaN' // Ok, that's expected //...but that isn't

JavaScript Calculations > 5 + 3 8 > '5' + 3 '53' > '5' 3 2 // String is converted to a number for subtraction > '5' '4' 1 // Both Strings converted to number for subtraction > '5' + + '4' 54 // Multiple +'s are ok > 'Hello' + 'World' 'HelloWorld' > 'Hello' + + 'World' 'HelloNaN' // Ok, that's expected // Multiple plus must cause String to number conversion

JavaScript Calculations > '5' + - '5' '5-2' // I can just about see that works > var x = 3 undefined > '5' x + x 5 // Ok, that makes sense > var x = 3 undefined > '5' + x - x 50 // What???

JavaScript Calculations > '5' + - '5' '5-2' // I can just about see that works > var x = 3 > '5' x + x 5 // Ok, that makes sense > var x = 3 undefined > '5' + x - x 50 // What???

JavaScript Calculations > '5' + - '5' '5-2' // I can just about see that works > var x = 3 > '5' x + x 5 // Ok, that makes sense > var x = 3 > '5' + x - x 50 // What???

Language Selection

Choosing the Right Language for the Service

Choosing the Right Language for the Service

Choosing the Right Language for the Service Node.js Performance Relative to Java + 1/3x 0 CPU Bound - 4x Application Performance (higher is better) Node.js I/O Bound * based on TechEmpower benchmark results

Choosing the Right Language for the Service Node.js Performance Relative to Java + 1/3x 0 CPU Bound - 4x Application Performance (higher is better) Node.js I/O Bound * based on TechEmpower benchmark results Error: incompatible types ClassCastException

Microservices Paradigm Do one thing, and do it well

Choosing the Right Language for the Service Higher performance for I/O Easier async programming Fullstack/isomorphic development

Choosing the Right Language for the Service Higher processing performance Type safety for calculations Rich processing frameworks

Choosing the Right Language for the Service + Highly performant, scalable rich web applications Highly performant, reliable transaction processing Self-contained micro-service components

Emerging Architectures

Rich Web Applications

Rich Web Applications

Rich Web Applications HTTP

Rich Web Applications HTTP Load Balancer

Rich Web Applications HTTP Load Balancer

Rich Web Applications Operations and Management Admin Analytics HTTP Load Balancer

Rich Web Applications Operations and Management Admin Analytics HTTP Load Balancer

Rich Web Applications Operations and Management Admin Analytics HTTP Load Balancer

Rich Web Applications Operations and Management Admin Analytics HTTP Load Balancer Load Balancer

Forrester 4-Tier Architecture

MicroServices and API Economy Operations and Management Admin Analytics HTTP Load Balancer Load Balancer

MicroServices and API Economy Operations and Management Admin Analytics HTTP Load Balancer Load Balancer

MicroServices and API Economy Operations and Management Admin Analytics HTTP Load Balancer Load Balancer

MicroServices and API Economy Operations and Management Admin Analytics HTTP Load Balancer Load Balancer

MicroServices and API Economy Operations and Management Admin Analytics HTTP Load Balancer

MicroServices and API Economy Operations and Management Admin Analytics HTTP Load Balancer

MicroServices and API Economy Operations and Management Admin Analytics HTTP Load Balancer

MicroServices and API Economy Operations and Management Admin Analytics HTTP Load Balancer

MicroServices and API Economy Operations and Management Admin Analytics HTTP Load Balancer

MicroServices and API Economy Operations and Management Admin Analytics HTTP Load Balancer Client Delivery Aggregation

Questions?

Thank You