Zero Latency HTTP the comet technique. Who am I Tomcat Committer / ASF member Co-designed the Comet implementation Implemented NIO connector.

Slides:



Advertisements
Similar presentations
HTTP and Apache Roy T. Fielding eBuilt, Inc. The Apache Software Foundation
Advertisements

CS193H: High Performance Web Sites Lecture 17: Rule 14 – Make Ajax Cacheable Steve Souders Google
4 Copyright © 2005, Oracle. All rights reserved. Creating the Web Tier: Servlets.
HTTP Reading: Section and COS 461: Computer Networks Spring
Building a Simple Web Proxy
Hypertext Transfer PROTOCOL ----HTTP Sen Wang CSE5232 Network Programming.
Fun Fun Project One1 Building Your Very Own Web Server.
Presenter: James Huang Date: Sept. 29,  HTTP and WWW  Bottle Web Framework  Request Routing  Sending Static Files  Handling HTML  HTTP Errors.
Web Server Sun Peng What is server - Question  First thing first! We need a definition: What is a server? ?
Introduction to Computing Using Python CSC Winter 2013 Week 8: WWW and Search  World Wide Web  Python Modules for WWW  Web Crawling  Thursday:
PHP syntax basics. Personal Home Page This is a Hypertext processor It works on the server side It demands a Web-server to be installed.
XML in the real world (2) SOAP. What is SOAP? ► SOAP stands for Simple Object Access Protocol ► SOAP is a communication protocol ► SOAP is for communication.
An Introduction to the Internet and the Web Frank McCown COMP 250 – Internet Development Harding University.
DEV034 -Web Applications, Introduction
TCP/IP Protocol Suite 1 Copyright © The McGraw-Hill Companies, Inc. Permission required for reproduction or display. Chapter 22 World Wide Web and HTTP.
Zero Latency HTTP the comet technique. Talk Sponsored By.
HTTP HyperText Transfer Protocol. HTTP Uses TCP as its underlying transport protocol Uses port 80 Stateless protocol (i.e. HTTP Server maintains no information.
Chapter 9 Application Layer, HTTP Professor Rick Han University of Colorado at Boulder
How the web works: HTTP and CGI explained
Definitions, Definitions, Definitions Lead to Understanding.
Christopher M. Pascucci Basic Structural Concepts of.NET Browser – Server Interaction.
Web technologies and programming cse hypermedia and multimedia technology Fanis Tsandilas April 3, 2007.
FALL 2005CSI 4118 – UNIVERSITY OF OTTAWA1 Part 4 Web technologies: HTTP, CGI, PHP,Java applets)
ASP.NET + Ajax Jesper Tørresø ITNET2 F08. Ajax Ajax (Asynchronous JavaScript and XML) A group of interrelated web development techniques used for creating.
CP476 Internet Computing Lecture 5 : HTTP, WWW and URL 1 Lecture 5. WWW, HTTP and URL Objective: to review the concepts of WWW to understand how HTTP works.
JavaScript, Fourth Edition Chapter 12 Updating Web Pages with AJAX.
WWW, HTTP, GET, POST, Cookies Svetlin Nakov Telerik Corporation
Orbited Scaling Bi-directional web applications A presentation by Michael Carter
Proxy Lab Recitation I Monday Nov 20, 2006.
World Wide Web “WWW”, "Web" or "W3". World Wide Web “WWW”, "Web" or "W3"
IS-907 Java EE World Wide Web - Overview. World Wide Web - History Tim Berners-Lee, CERN, 1990 Enable researchers to share information: Remote Access.
2: Application Layer 1 Chapter 2: Application layer r 2.1 Principles of network applications  app architectures  app requirements r 2.2 Web and HTTP.
Web Technologies Lecture 1 The Internet and HTTP.
CSI 3125, Preliminaries, page 1 SERVLET. CSI 3125, Preliminaries, page 2 SERVLET A servlet is a server-side software program, written in Java code, that.
Summer 2007 Florida Atlantic University Department of Computer Science & Engineering COP 4814 – Web Services Dr. Roy Levow Part 1 – Introducing Ajax.
CS 6401 The World Wide Web Outline Background Structure Protocols.
Overview of Servlets and JSP
What’s Really Happening
Research of Web Real-Time Communication Based on WebSocket
How HTTP Works Made by Manish Kushwaha.
WWW and HTTP King Fahd University of Petroleum & Minerals
Building Web Apps with Servlets
Web Basics: HTML and HTTP
HTTP – An overview.
The Hypertext Transfer Protocol
How does it work ?.
1993 version of Mosaic browser.
COMP2322 Lab 2 HTTP Steven Lee Feb. 8, 2017.
Hypertext Transport Protocol
Introduction Web Environments
AJAX.
TCP/IP Networking An Example
HTTP Protocol.
Uniform Resource Locators
WEB API.
AJAX Robin Burke ECT 360.
CS320 Web and Internet Programming Cookies and Session Tracking
HTTP Request Method URL Protocol Version GET /index.html HTTP/1.1
Uniform Resource Locators (URLs)
CS3220 Web and Internet Programming Cookies and Session Tracking
Hypertext Transfer Protocol (HTTP)
CS3220 Web and Internet Programming Handling HTTP Requests
The Application Layer: HTTP
Uniform Resource Locators

CS3220 Web and Internet Programming Cookies and Session Tracking
CSCI-351 Data communication and Networks
Presentation transcript:

Zero Latency HTTP the comet technique

Who am I Tomcat Committer / ASF member Co-designed the Comet implementation Implemented NIO connector in 6 Responsible for session replication and clustering Been involved with ASF since 2001

What we will cover Brief History of HTTP How HTTP is used today Introduction to AJAX Beyond AJAX, The Comet Technique Comet Implementation – Under the hood Uni- vs. Bidirectional Comet Problems and their solutions Demo Q & A

The History of HTTP 1.0 (7th release) RFC 1945 in 1996 Co-authored by ASFs Roy T Fielding Current RFC 2616 Lead by W3C Activity on specs are closed Standard has been achieved

What is HTTP HyperText Transfer Protocol Text based protocol Request/Response semantics Stateless Most commonly run over TCP/IP networks Protocol used for much more than just hypermedia information sharing

What is HTTP Text based protocol – CRLN delimited GET /Protocols/History.html HTTP/1.1 Host: User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv: ) Gecko/ Firefox/ Accept: text/xml,application/xml,application/xhtml+xml,text/h tml;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO ,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive

What is HTTP Request/Response Semantics GET /Protocols/History.html HTTP/1.1 Host: Keep-Alive: 300 Connection: keep-alive HTTP/1.x 200 OK Date: Mon, 19 Mar :46:17 GMT Server: Apache/ (Unix) PHP/4.4.5 Keep-Alive: timeout=2, max=100 Content-Length: Connection: Keep-Alive Request Response

What is HTTP Stateless –TCP session can end after each request –State based on cookies TCP/IP transport –No limitations for transporting with other protocols Delivers both text and binary data

HTTP Limitations Request/Response –Change one field on a page requires a reload of the entire page –Client always has to initiate the request Stateless –Server required to keep state –State is timed out, if client is not cancelling it Finer grained communication is needed –AJAX –Rich Clients (FLEX, OpenLaszlo, …)

AJAX Asynchronous JavaScript +(and) XML Uses HTTP Asynchronous data processing Able to request data from server and update a page in the browser Common examples –maps.google.com

Benefits of AJAX Performance –More can be accomplished in less amount of transactions Less user interaction –Program can make intelligent decision about when a request needs to happen and what data it needs to fetch Sample Application for view of benefits –

Beyond AJAX What did AJAX not accomplish? –Still client poll based –Server push can be accomplished by a client poll followed by a delayed response –Traditional web/servlet containers are thread-per-request based –Server resource tied up for the duration of the request

Introducing Comet The answer to our problems –Q: What problems? –A: The fact that port HTTP/80 has been replacing every decent TCP protocol over the years. –Q: What do you mean? –A: Ill explain…

Picture borrowed from: dojotoolkit.org

3. Register with background thread How it Works Timeline Server Client 1. HTTP request 2. BEGIN Event 5. HTTP Response OK – Tx Enc: Chunked 4. Event Complete Webapp Async Thread 6. Server data push 7. Encode and transfer8. Another server push9. Client Push10. READ Event11. One more client push Webapp Worker Thread 12. And on it goes…

Under the hood Open HTTP request, leave it open ended Instant or delayed response(s), leave it open ended Tomcat processes just like servlet –CometProcessor extends HttpServlet(or should) –CometFilter extends Filter Connection remains open and is writable

Under the Hood Open ended request POST /load/echo HTTP/1.1 User-Agent: Filips Comet Client/1.0 Host: :8080 Transfer-Encoding: chunked 10 test data test 1 Open ended allows for new data without the overhead for a new request –Zero Latency HTTP

Under the Hood Open ended response HTTP/ OK Server: Apache-Coyote/1.1 Transfer-Encoding: chunked Content-Type: text/plain;charset=UTF-8 Transfer-Encoding: chunked Date: Mon, 19 Mar :25:36 GMT 12 test data test 1 Open ended allows for new data without the overhead for a new request –Zero Latency HTTP

Under the Hood CometProcessor –Extends HttpServlet to provide a fall back option should the connector not support Comet void event(CometEvent event)… –Types of Events: BEGIN READ END ERROR A request is a Comet request if the URL maps to a servlet that implements the CometProcessor interface

Under the Hood CometFilter –Extends javax.servlet.Filter to provide fall back option should the Connector not support Comet void doFilterEvent(CometEvent event, CometFilterChain chain) … Same mapping rules as CometProcessor

Under the Hood BEGIN –New connection created –Request headers fully parsed and mapped to a servlet –Partial body may or may not have been read –Processed by a worker thread

Under the Hood READ –New data available on the connection –Processed by worker thread –Read now to avoid repeated read events –Read using servlet input stream event.getHttpServletRequest.getInputStrea m()

Under the Hood END –The request has naturally come to an end –Server may shutdown, and needs to close connections –Only if Connector shutdown prior to app, piggy back on HttpServlet.destroy for most apps instead ERROR –When the connection times out or an error has occurred during invokation

Bidirectional Comet Tomcat supports bidirectional comet communication –Server can push data to the client –Client can push data to the server Timeout values can be set on a per- connection basis Unidirectional Comet means that only the server can push data to client

Scalability? No more thread per connection or thread per request One asynch thread can handle writes for thousands of Comet connections No overhead of request/response headers for each request No overhead for TCP setup/breakdown Memory overhead for open connections

Examples of use Rich Clients –Mail –Maps –Online conferences Clients with need for server push –Stock tickers –Auction sites –Chat

Future Improvements Non blocking reads Non blocking writes Bayeux protocol implementation End Request – AJAX over Comet Keepalive Connections Comet through HTTP proxy(?)

Demo Instructions for demo usage Demo consists of an interactive application Use this application to evaluate the session you just listened to …. …..