Kaazing Gateway: An Open Source HTML 5 Websocket Server HTML 5 - - PowerPoint PPT Presentation

kaazing gateway an open source html 5 websocket server
SMART_READER_LITE
LIVE PREVIEW

Kaazing Gateway: An Open Source HTML 5 Websocket Server HTML 5 - - PowerPoint PPT Presentation

Kaazing Gateway: An Open Source HTML 5 Websocket Server HTML 5 Websocket Server Speaker Jonas Jacobi Co-Founder: Kaazing Co-Author: Pro JSF and Ajax, Apress Agenda Real-Time Web? Why Do I Care? Scalability and


slide-1
SLIDE 1
slide-2
SLIDE 2

Kaazing Gateway: An Open Source HTML 5 Websocket Server HTML 5 Websocket Server

slide-3
SLIDE 3

Speaker

  • Jonas Jacobi
  • Co-Founder: Kaazing
  • Co-Author: Pro JSF and Ajax, Apress
slide-4
SLIDE 4

Agenda

  • Real-Time Web? Why Do I Care?
  • Scalability and Performance Concerns
  • Comet
  • Is This It?
  • Is This It?
slide-5
SLIDE 5

Defining Real-Time Web

Web Applications Typically Not Real-Time

slide-6
SLIDE 6

Defining Real-Time Web

  • Web Clients Receive Server Updates

– Server-initiated communication

  • End-Users Receive Updates

Simultaneously Simultaneously

– Collaboration

slide-7
SLIDE 7

Defining Real-Time Web

Or, is it just nearly, nearly real-time?

Maybe we should rename it to something else – Event-Driven Web?

slide-8
SLIDE 8

Ajax (XHR)

  • Updates Limited To Preset Interval

– Message buffering increases memory usage – Near real-time updates achieved with shorter intervals intervals

  • Shorter Updates Cause

– Increased network traffic – Higher frequency connection setup & teardown

slide-9
SLIDE 9

Push Technology History

  • Push technology has been around for a

while:

– Pushlets (2002) – Bang Networks (early adopter) – Bang Networks (early adopter)

  • Previous attempts failed, because:

– Scalability Limitations (Cost etc…) – Not general purpose – No standard

slide-10
SLIDE 10

Push Technology

  • Server-Initiated Message Delivery

– Clients are listening – Clients behind firewalls

  • Techniques such as Comet/Reverse Ajax
  • Techniques such as Comet/Reverse Ajax
  • Delays Completion of HTTP Response
  • Generally Implemented in JS
slide-11
SLIDE 11

Long Polling and Streaming

  • Current Comet implementations center

around two major areas:

– Long Polling – Streaming – Streaming

slide-12
SLIDE 12

Long Polling

  • Also known as asynchronous-polling
  • Request open for a set period.
  • HTTP headers often account for more

than half of the network traffic. than half of the network traffic.

slide-13
SLIDE 13

Long Polling HTTP Request

From client (browser) to server:

GET /long-polling HTTP/1.1\r\n Host: www.kaazing.com\r\n User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9) Gecko/2008061017 Firefox/3.0\r\n Accept: Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8 \r\n Accept-Language: en-us,en;q=0.5\r\n Accept-Encoding: gzip,deflate\r\n Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7\r\n Keep-Alive: 300\r\n Connection: keep-alive\r\n Cache-Control: max-age=0\r\n \r\n

slide-14
SLIDE 14

Long Polling HTTP Response

From server to client (browser):

Date: Tue, 16 Aug 2008 00:00:00 GMT\r\n Server: Apache/2.2.9 (Unix)\r\n Server: Apache/2.2.9 (Unix)\r\n Content-Type: text/plain\r\n Content-Length: 12\r\n \r\n Hello, world

slide-15
SLIDE 15

HTTP Streaming

  • Persistent HTTP Connection

– Pending POST

  • Minimizes Latency
  • Reduction in Network Traffic
  • Reduction in Network Traffic
  • Optimizes Connection Setup & Tear-Down

– Keep-alive – Security

slide-16
SLIDE 16

Concurrency

  • Many Concurrent Synchronous Requests
  • Standard Java EE Containers

– Designed For Short-Lived Request/Response – One open socket per thread – One open socket per thread

slide-17
SLIDE 17

Solutions: Vertical Scalability

  • Asynchronous Request Processing (ARP)

– Java NIO – Twisted (Python) – POE (Perl) – POE (Perl)

  • Decouples Connections from Threads

– Jetty Continuations – Grizzly CometEngine – Tomcat6 CometProcessor

slide-18
SLIDE 18

Today’s Architecture

Java EE Container

sport Logic EJB

RMI - TCP (Full Duplex) JDBC - TCP (Full Duplex)

Database JavaMail IMAP Server

IMAP - TCP (Full Duplex) RMI

Servlet

Browser

Application Transpo JMS

HTTP (Half Duplex)

Stock Trading Client IM Server JavaMail IMAP Server

JABBER - TCP (Full Duplex) JMS - TCP (Full Duplex) RMI

JMS Stock Trading Feed

Custom - TCP (Full Duplex)

slide-19
SLIDE 19

What’s Missing?

  • Not a standard
  • No true bi-directional communication
  • No guaranteed message delivery
  • Complex middle-tier architecture
  • Complex middle-tier architecture

– Adds unnecessary latency

slide-20
SLIDE 20

Evolving the Web

Server Server

Ajax Comet/Reverse Ajax

ct ct Server

WebSockets

ct ct Browser Browser

Firewall

Polling Notify Connect Notify Connect Notify

Firewall

Browser Connect Notify Connect Notify

Firewall

slide-21
SLIDE 21

HTML 5 WebSockets

  • The Communication section:

– WebSockets – Server-sent events

  • Not New; TCPConnection API and
  • Not New; TCPConnection API and

protocol were initially drafted over two years ago

  • HTML 5 – Final draft by 2022?!
slide-22
SLIDE 22

Server-Sent Events

  • Standardizes and formalizes how a

continuous stream of data can be sent from a server to a browser

  • Introduces eventsource—a new DOM
  • Introduces eventsource—a new DOM

element

slide-23
SLIDE 23

Server-Sent Events

  • Connects to a server URL to receive an

event stream: <eventsource src= "http://stocks.kaazing.com" "http://stocks.kaazing.com"

  • nmessage="alert(event.data)">
slide-24
SLIDE 24

Server Sent-Events

  • Server can add the ID header so that

clients add a Last-Event-ID header

  • Used to guarantee message delivery
  • Server specify an optional retry header as
  • Server specify an optional retry header as

part of an event in the event stream

slide-25
SLIDE 25

WebSockets

  • Defines full-duplex communications

– Operates over a single socket

  • Traverses firewalls and routers seamlessly
  • Allows authorized cross-domain
  • Allows authorized cross-domain

communication

  • Integrates with:

– Cookie-based authentication – Existing HTTP load balancers

slide-26
SLIDE 26

WebSockets

  • Connection established by upgrading from

the HTTP protocol to the WebSocket protocol

  • WebSocket data frames can be sent back
  • WebSocket data frames can be sent back

and forth between the client and the server in full-duplex mode

slide-27
SLIDE 27

WebSockets

  • Supports a diverse set of clients
  • Cannot deliver raw binary data to

JavaScript

– Binary data is ignored if the client is – Binary data is ignored if the client is JavaScript

  • Enables direct communication with

backend systems

slide-28
SLIDE 28

WebSockets

  • Detects presence of proxy servers
  • A tunnel is established by issuing an HTTP

CONNECT statement

  • Secure Web sockets over SSL can
  • Secure Web sockets over SSL can

leverage the same HTTP CONNECT technique

slide-29
SLIDE 29

Simplified Architecture

Java EE EJB JDBC - TCP (Full Duplex)

Database

JDBC - TCP (Full Duplex) RMI - TCP (Full Duplex) JMS RMI - TCP (Full Duplex)

erver

Browser

TCP over HTTP (Full Duplex) IMAP - TCP (Full Duplex) Jabber - TCP (Full Duplex)

Stock Trading Feed

Custom - TCP (Full Duplex)

IM Server IMAP Server

WebSocket Serv

slide-30
SLIDE 30

WebSockets

  • Creating a WebSocket instance:

var myWebSocket = new WebSocket (“ws://www.websocket.org”); (“ws://www.websocket.org”);

slide-31
SLIDE 31

WebSockets

  • Associating listeners:

myWebSocket.onopen = function(evt) { alert(“Connection open ...”); }; myWebSocket.onmessage = function(evt) { alert( “Received Message: ” + evt.data); }; myWebSocket.onclose = function(evt) { alert(“Connection closed.”); };

slide-32
SLIDE 32

WebSockets

  • Sending messages:

myWebSocket.postMessage(“Hello Web Socket! Goodbye Comet!”); Socket! Goodbye Comet!”); myWebSocket.disconnect();

slide-33
SLIDE 33

WebSocket Servers

  • Kaazing Gateway

– Open source – Standards compliant – Binary and text support – Binary and text support – Production Release Sept 29th, 2008

  • Orbited

– Python open source project

slide-34
SLIDE 34

Kaazing Gateway

  • Enables full-duplex communication to any

TCP-based back-end service:

  • JMS
  • Jabber
  • Jabber
  • Stomp
  • etc…
slide-35
SLIDE 35

Kaazing Gateway

  • Based on SEDA (Staged Event-Driven

Architecture)

– Leverages Java New I/O (NIO)

  • Simplifies architecture
  • Simplifies architecture

– Low Latency

  • Client-side emulation of the standard if no

browser support is available

  • Full-duplex binary and text communication
slide-36
SLIDE 36

Kaazing Gateway

  • Scalability?
  • ENOUGH
slide-37
SLIDE 37

Summary

  • Event-Driven Solutions Are Required For a

Multi-User Web

  • WebSockets and SSE standardize Comet
  • Available now!
  • Available now!
slide-38
SLIDE 38