All You Can Eat Realtime



Similar documents
Research of Web Real-Time Communication Based on Web Socket

Real Time Data Communication over Full Duplex Network Using Websocket

FIVE SIGNS YOU NEED HTML5 WEBSOCKETS

Hypertext for Hyper Techs

CONTENT of this CHAPTER

High Performance Messaging for Web-based Trading Systems. Frank Greco Director of Technology, Kaazing

HTML5 Websockets with ruby and rails. Saurabh Bhatia, CEO, Safew Labs

Research on Server Push Methods in Web Browser based Instant Messaging Applications

CS640: Introduction to Computer Networks. Applications FTP: The File Transfer Protocol

Security-Assessment.com White Paper Leveraging XSRF with Apache Web Server Compatibility with older browser feature and Java Applet

DEPLOYMENT GUIDE Version 1.1. Deploying the BIG-IP LTM v10 with Citrix Presentation Server 4.5

LBL Application Availability Infrastructure Unified Secure Reverse Proxy

Repeater. BrowserStack Local. browserstack.com 1. BrowserStack Local makes a REST call using the user s access key to browserstack.

Step into the Future: HTML5 and its Impact on SSL VPNs

Internet Technologies Internet Protocols and Services

Integrating Web Messaging into the Enterprise Middleware Layer

HTTP/2: Operable and Performant. Mark

THE PROXY SERVER 1 1 PURPOSE 3 2 USAGE EXAMPLES 4 3 STARTING THE PROXY SERVER 5 4 READING THE LOG 6

Study of HTML5 WebSocket for a Multimedia Communication

HTTP Response Splitting

HTTP. Internet Engineering. Fall Bahador Bakhshi CE & IT Department, Amirkabir University of Technology

Network Technologies

Computer Networks. Lecture 7: Application layer: FTP and HTTP. Marcin Bieńkowski. Institute of Computer Science University of Wrocław

Lab Exercise SSL/TLS. Objective. Step 1: Open a Trace. Step 2: Inspect the Trace

Modern Web Development From Angle Brackets to Web Sockets

INUVIKA OPEN VIRTUAL DESKTOP FOUNDATION SERVER

Flexible Routing and Load Control on Back-End Servers. Controlling the Request Load and Quality of Service

SiteCelerate white paper

HTTP Caching & Cache-Busting for Content Publishers

International Journal of Engineering & Technology IJET-IJENS Vol:14 No:06 44

Question: 3 When using Application Intelligence, Server Time may be defined as.

Table of Contents. Open-Xchange Authentication & Session Handling. 1.Introduction...3

DOCUMENT REFERENCE: SQ EN. SAMKNOWS TEST METHODOLOGY Web-based Broadband Performance White Paper. July 2015

Network Configuration Settings

1 Introduction: Network Applications

This section contains information intended to help plan for SocialMiner installation and deployment.

DEPLOYMENT GUIDE DEPLOYING THE BIG-IP LTM SYSTEM WITH CITRIX PRESENTATION SERVER 3.0 AND 4.5

F5 Big-IP LTM Configuration: HTTPS / WSS Offloading

1. The Web: HTTP; file transfer: FTP; remote login: Telnet; Network News: NNTP; SMTP.

How To Connect To Bloomerg.Com With A Network Card From A Powerline To A Powerpoint Terminal On A Microsoft Powerbook (Powerline) On A Blackberry Or Ipnet (Powerbook) On An Ipnet Box On

Deployment Guide Microsoft IIS 7.0

Web Application Security

The Hyper-Text Transfer Protocol (HTTP)

HTTPS HTTP. ProxySG Web Server. Client. ProxySG TechBrief Reverse Proxy with SSL. 1 Technical Brief

reference: HTTP: The Definitive Guide by David Gourley and Brian Totty (O Reilly, 2002)

Live Guide System Architecture and Security TECHNICAL ARTICLE

ICSA Labs Web Application Firewall Certification Testing Report Web Application Firewall - Version 2.1 (Corrected) Radware Inc. AppWall V5.6.4.

Cyber Security Workshop Ethical Web Hacking

Web Enabling Solution for Windows Desktop Applications. White Paper

Architecture and Data Flow Overview. BlackBerry Enterprise Service Version: Quick Reference

Centralized logging system based on WebSockets protocol

HTTP Protocol. Bartosz Walter

Internet Technologies. World Wide Web (WWW) Proxy Server Network Address Translator (NAT)

tibbr Now, the Information Finds You.

The Web: some jargon. User agent for Web is called a browser: Web page: Most Web pages consist of: Server for Web is called Web server:

Internet Explorer 10 Internet Explorer 11. Internet Explorer 10

Research and Performance Analysis of HTML5 WebSocket for a Real-time Multimedia Data Communication Environment

bbc Adobe LiveCycle Data Services Using the F5 BIG-IP LTM Introduction APPLIES TO CONTENTS

Protocolo HTTP. Web and HTTP. HTTP overview. HTTP overview

Real Time Data in Web Applications

Lab Exercise SSL/TLS. Objective. Requirements. Step 1: Capture a Trace

FRAFOS GmbH Windscheidstr. 18 Ahoi Berlin Germany

This presentation discusses the new support for the session initiation protocol in WebSphere Application Server V6.1.

MEGA Web Application Architecture Overview MEGA 2009 SP4

v7.7.3 Release Notes for Websense Content Gateway

Monitoring Nginx Server

Polyglot: Automatic Extraction of Protocol Message Format using Dynamic Binary Analysis

Anatomy of a Pass-Back-Attack: Intercepting Authentication Credentials Stored in Multifunction Printers

VoIP LAB. 陳 懷 恩 博 士 助 理 教 授 兼 所 長 國 立 宜 蘭 大 學 資 訊 工 程 研 究 所 TEL: # 255

Nuance Mobile Developer Program. HTTP Services for Nuance Mobile Developer Program Clients

WebLogic & Coherence. Best backend for Mobile Apps. July 2014 INSERT PRESENTER TITLE AND DATE

CA CPT CICS Programmers Toolkit for TCP/IP r6.1

Playing with Web Application Firewalls

Vodia PBX RESTful API (v2.0)

Building Instant Messaging and Chat over WebSocket with XMPP

Interwise Connect. Working with Reverse Proxy Version 7.x

A host-based firewall can be used in addition to a network-based firewall to provide multiple layers of protection.

Addressing Mobile Load Testing Challenges. A Neotys White Paper

TCP/IP Networking An Example

Web Architecture I u

Configuring Health Monitoring

SSL Inspection Step-by-Step Guide. June 6, 2016

Barracuda Networks Web Application Firewall

Bridgit Conferencing Software: Security, Firewalls, Bandwidth and Scalability

HP Service Manager Architecture and Security HP Software-as-a-Service

ShoreTel Advanced Applications Web Utilities

Configuration Guide. BES12 Cloud

KEMP LoadMaster. Enabling Hybrid Cloud Solutions in Microsoft Azure

TFE listener architecture. Matt Klein, Staff Software Engineer Twitter Front End

WISE-4000 Series. WISE IoT Wireless I/O Modules

Project #2. CSE 123b Communications Software. HTTP Messages. HTTP Basics. HTTP Request. HTTP Request. Spring Four parts

CTERA Agent for Mac OS-X

Pwning Intranets with HTML5

Study of the architecture for a new webbased software system using commercial ERP system

Transcription:

HTML5 WebSocket: All You Can Eat Realtime By Peter Lubbers, Kaazing May 14, 2010 1

About Peter Lubbers Director of Documentation and Training, Kaazing Co-Founder San Francisco HTML5 User Group http://www.sfhtml5.org/ Twitter: @peterlubbers Co-author Pro HTML5 Programming o Alpha Release: www.prohtml5.com o Special 50% Off Coupon Code: APRESSPROHTML5WR (expires May 31st) Ultra Distance Runner 2

Agenda HTML5 WebSocket o Tin-can communication o Meet HTML5 WebSocket o HTML5 WebSocket in the enterprise o Scaling through simplicity 3

HTML5 WebSocket 4

Today s Requirements Today s Web applications demand reliable, realtime communications with near-zero latency Not just broadcast, but bi-directional communication Examples: o Financial applications o Social networking applications o Online games o Smart power grid 5

The Perils of Polling No-fly list not updated 6

HTTP Is Not Full Duplex 7

About HTTP HTTP was originally designed for document transfer Until now, it has been cumbersome to achieve real-time, bi-directional web communication due to the limitations of HTTP HTTP is half-duplex (traffic flows in only one direction at a time) Header information is sent with each HTTP request and response, which can be an unnecessary overhead 8

About Ajax and Comet Great toilet cleaners Ajax (Asynchronous JavaScript and XML) can be used to build interactive Web apps o Content can change without refreshing the entire page o User-perceived low latency Real-time often achieved through polling and long-polling (Comet or Reverse Ajax) o Comet lack of a standard implementation o Comet adds lots of complexity 9

Half-Duplex Architecture 10

Polling Architecture 11

Polling Polling is nearly real-time Used in Ajax applications to simulate realtime communication Browser sends HTTP requests at regular intervals and immediately receives a response In low-message-rate situations, many connections are opened and closed needlessly 12

Long Polling Architecture 13

Long Polling Also known as asynchronous-polling Browser sends a request to the server and the server keeps the request open for a set period HTTP headers, present in both longpolling and polling often account for most of the network traffic In high-message rate situations, longpolling results in a continuous loop of immediate polls 14

Streaming Architecture 15

Streaming More efficient, but sometimes problematic Possible complications: o Proxies and firewalls o Response builds up and must be flushed periodically o Cross-domain issues to do with browser connection limits 16

Comet Demo 17

HTTP Request Headers POST /gwt/eventservice HTTP/1.1 Host: gpokr.com Connection: keep-alive User-Agent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-us) AppleWebKit/532.5 (KHTML, like Gecko) Chrome/4.1.249.1064 Safari/532.5 Referer: http://gpokr.com/gwt/7f5e66657b938e2fde9cd39095a0e9e6.cache.html Content-Length: 134 Origin: http://gpokr.com Content-Type: text/plain; charset=utf-8 Accept: */* Accept-Encoding: gzip,deflate,sdch Accept-Language: en-us,en;q=0.8 Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.3 Cookie: utmz=247824721.1273102477.1.1.utmcsr=(direct) utmccn=(direct) utmcmd =(none); JSESSIONID=E7AAE0E60B01FB88D1E3799FAD5C62B3; utma=247824721.1247485893.1273102477.1273104838.1273107686.3; utmc=247824721; utmb=247824721.4.10.127 18

HTTP Response Headers 200 OK Server: Apache-Coyote/1.1 Expires: Thu, 06 May 2010 01:06:51 GMT Content-Type: text/plain;charset=utf-8 Content-Length: 303 Date: Thu, 06 May 2010 01:06:50 GMT Total (unnecessary) HTTP request and response header information overhead: 871 bytes (example) Overhead can be as much as 2000 bytes 19

HTTP Header Traffic Analysis Example network throughput for HTTP request and response headers associated with polling Use case A: 1,000 clients polling every second: Network throughput is (871 x 1,000) = 871,000 bytes = 6,968,000 bits per second (~6.6 Mbps) Use case B: 10,000 clients polling every second: Network throughput is (871 x 10,000) = 8,710,000 bytes = 69,680,000 bits per second (~66 Mbps) Use case C: 100,000 clients polling every second: Network throughput is (871 x 100,000) = 87,100,000 bytes = 696,800,000 bits per second (~665 Mbps) 20

Comet: Headache 2.0 21

22

Vote NO on Tin Cans and String for Communication! 23

Enter HTML5 WebSocket! 24

HTML5 WebSocket W3C API and IETF Protocol Full-duplex text-based socket Enables web pages to communicate with a remote host Traverses firewalls, proxies, and routers seamlessly Leverages Cross-Origin Resource Sharing (CORS) Share port with existing HTTP content (80/443) 25

Pop Quiz What does WebSocket have in common with model trains? 26

Possible WebSocket Architecture 27

HTML5 WebSocket Schemes WebSocket o ws://www.websocket.org/text WebSocket Secure o wss://www.websocket.org/encrypted-text 28

HTML5 WebSocket Connection established by upgrading from the HTTP protocol to the WebSocket protocol using the same TCP connection Once upgraded, WebSocket data frames can be sent back and forth between the client and the server in full-duplex mode 29

HTML5 WebSocket Handshake Client GET /text HTTP/1.1 Upgrade: WebSocket Connection: Upgrade Host: www.example.com Origin: http://example.com WebSocket-Protocol: sample \r\n 30 Server HTTP/1.1 101 WebSocket Protocol Handshake Upgrade: WebSocket Connection: Upgrade WebSocket-Origin: http://example.com WebSocket-Location: ws://example.com/demo WebSocket-Protocol: sample \r\n

HTML5 WebSocket Frames Frames can be sent full-duplex, in either direction at any the same time 31 Each frame of data: o Starts with a 0x00 byte and End with a 0xFF byte o Contains UTF-8 data in between Example: o \x00hello, WebSocket\0xff There is no defined maximum size o If the user agent has content that is too large to be handled, it must fail the Web Socket connection o JavaScript does not allow >4GB of data, so that is a practical maximum

Using the WebSocket API 32

Checking For Browser Support JavaScript //Checking for browser support if (window.websocket) { document.getelementbyid("support").innerhtml = "HTML5 WebSocket is supported"; } else { document.getelementbyid("support").innerhtml = "HTML5 WebSocket is not supported"; } 33

Using the WebSocket API JavaScript //Create new WebSocket var mysocket = new WebSocket( ws://www.websocket.org ); // Associate listeners mysocket.onopen = function(evt) { alert( Connection open ); }; mysocket.onmessage = function(evt) { alert( Received message: + evt.data); }; mysocket.onclose = function(evt) { alert( Connection closed ); }; 34

Using the WebSocket API JavaScript // Sending data mysocket.send( HTML5 WebSocket Rocks! ); //Close WebSocket mysocket.close(); 35

Browser Support for WebSocket Chrome 4.0+ WebKit Nightly builds Support planned for Firefox: We really really want to support WebSockets in the next version of Firefox. Christopher Blizzard, Mozilla 36

Example: Native WebSocket in Chrome 37

WebSocket Emulation Kaazing WebSocket Gateway http://www.kaazing.com/download Makes WebSocket work in all browsers today (including I.E. 6) Flash WebSocket implementation http://github.com/gimite/web-socket-js Requires opening port on the server s firewall 38

Beyond WebSocket Once you have WebSocket, you can communicate with WebSocket Servers and backend servers and directly with message brokers You can extend client-server protocols to the web: 39 XMPP, Jabber Pub/Sub (Stomp/AMQP) Gaming protocols Any TCP-based protocol Browser becomes a first-class network communication citizen

Financial Applications 40

Example: WebSocket- Based Quake II Game Port 41 http://code.google.com/p/quake2-gwt-port

Twitter Feed 42 http://kaazing.me

43 WebSocket in the Enterprise

WebSocket and Web Intermediaries Web Socket protocol itself is unaware of proxy servers and firewalls WebSocket features an HTTP-compatible handshake so that HTTP servers can share their default HTTP and HTTPS ports (80 and 443) with a WebSocket server 44

45 Securing WebSocket Traffic WebSocket defines the ws:// and wss:// schemes WSS is WS over TLS (Transport Layer Security), formerly known as SSL (Secure Socket Layer) support (Similar to HTTPS) An HTTPS connection is established after a successful TLS handshake (using public and private key certificates) HTTPS is not a separate protocol, but it is HTTP running on top of a TLS connection (default ports is 443)

Proxy Servers A proxy server is a server that acts as an intermediary between a client and another server (for example, a web server on the Internet) Commonly used for content caching, Internet connectivity, security, and enterprise content filtering May also buffer unencrypted HTTP responses, thereby introducing unpredictable latency during HTTP response streaming 46

Types of Proxy Servers 47

WebSocket Proxy Traversal 48 http://www.infoq.com/articles/web-sockets-proxy-servers

Load Balancing Routers TCP (layer-4) load-balancing routers should work well with HTML5 Web Sockets, because they have the same connection profile: connect once up front and stay connected, rather than the HTTP document transfer request-response profile HTTP (Layer 7) load-balancing routers expect HTTP traffic and can easily get confused by WebSocket upgrade traffic. For that reason, Layer 7 load balancing routers may need to be configured to be explicitly aware of WebSocket traffic 49

Firewalls Since firewalls normally just enforce the rules for inbound traffic rejection and outbound traffic routing (for example, through the proxy server), there are usually no specific WebSocket traffic-related firewall concerns For regular socket connections (for example, for a desktop client) you must open a port on the firewall 50

51 WebSocket Traffic Analysis

WebSocket Demo 52

Dramatic Reduction in Network Traffic With WebSocket, each frame has only 2 bytes of packaging (a 500:1 or even 1000:1 reduction) No latency involved in establishing new TCP connections for each HTTP message Dramatic reduction in unnecessary network traffic and latency Remember the Polling HTTP header traffic? 665 Mbps network throughput for just headers 53

WebSocket Framing Analysis Example network throughput overhead associated with WebSocket framing Use case A: 1,000 clients receive 1 message per second: Network throughput is (2 x 1,000) = 2,000 bytes = 16,000 bits per second (~0.015 Mbps) Use case B: 10,000 clients receive 1 message per second: Network throughput is (2 x 10,000) = 20,000 bytes = 160,000 bits per second (~0.153 Mbps) Use case C: 100,000 clients receive 1 message per second: Network throughput is (2 x 100,000) = 200,000 bytes = 1,600,000 bits per second (~1.526 Mbps) 54

Polling vs. WebSocket 55

Latency Reduction 56

Overheard Reducing kilobytes of data to 2 bytes and reducing latency from 150ms to 50ms is far more than marginal. In fact, these two factors alone are enough to make WebSocket seriously interesting to Google. Ian Hickson (Google, HTML5 spec lead) 57

Q&A 58

GeeCON Special! HTML5ROCKS 10% Off Any HTML5 Training With Coupon Code HTML5ROCKS http://tech.kaazing.com/training/index.html 59

Copyright 2010 Kaazing Corporation, All rights reserved. All materials, including labs and other handouts are property of Kaazing Corporation. Except when expressly permitted by Kaazing Corporation, you may not copy, reproduce, publish, or display any part of this training material, in any form, or by any means. 60

61