comet: an overview and a new solution called jabbify

23
Comet Overview Brian Moschel Jupiter IT

Upload: brian-moschel

Post on 15-Jan-2015

2.986 views

Category:

Technology


3 download

DESCRIPTION

Brian Moschel delivered this talk at the JS.Chi() April 2009 meetup. This talk provides an overview of Comet, also known as HTTP Push, covering how it works on the server and client, several implementation options, and using a new Comet API called Jabbify in an interactive demo.

TRANSCRIPT

Page 1: Comet: an Overview and a New Solution Called Jabbify

Comet Overview

Brian MoschelJupiter IT

Page 2: Comet: an Overview and a New Solution Called Jabbify

Overview

Why Comet?

Comet Overvie

wJabbify How It

Works Demo Showcase

Page 3: Comet: an Overview and a New Solution Called Jabbify

Why Comet?

• Web 2.0 Trends1. Time Spent on a Page

Page 4: Comet: an Overview and a New Solution Called Jabbify

Why Comet?

• Web 2.0 Trends2. Half life of a Page’s Content

Page 5: Comet: an Overview and a New Solution Called Jabbify

Why Comet?

• Demand for Comet is growing• Desktop apps moving to the web

• Chat• Real time updates• Don’t like to reload

• Ajax:2003::Comet:2009

Page 6: Comet: an Overview and a New Solution Called Jabbify

Uses

• Multi user collaboration apps– Wiki– Presentation

• Communication– Chat

• Preventing stale data– Stock ticker– Social web updates

• Others?

Page 7: Comet: an Overview and a New Solution Called Jabbify

Polling

Comet Long Polling

Server

Client

Server

Client

Are weThere yet? No

Are weThere yet? No

Are weThere yet? No

Wait for data

Polling vs. Comet

Wait for data

Page 8: Comet: an Overview and a New Solution Called Jabbify

How Comet Works: Client Side• Long Poll

– How?• XHR, JSONP, or any transport, with connection held open

– Pro• It works cross browser

– Con• More overhead

• Forever Frame– How?

• Iframe• Multipart XHR

– Pro• Less overhead, quicker responses

– Con• Lack of error handling, not cross browser

Page 9: Comet: an Overview and a New Solution Called Jabbify

Client Side Issues

• Cross Browser– Duh

• 2 Connection Limit– Use wildcard DNS– Xxx.mywebsite.com -> mywebsite.com

• Synchronous request s (for JSONP)– Long poll has to close to allow other requests to

process

Page 10: Comet: an Overview and a New Solution Called Jabbify

How Comet Works: Server Side

• Simultaneous connections– Traditional servers can’t scale– A thread shared multiple connections

• Wake up when you’re ready to send data

Page 11: Comet: an Overview and a New Solution Called Jabbify

How Comet Works: Server Side

• Python– Orbited– Cometd

• Java– Jetty

• Erlang– ErlyComet

• .NET– Lightstreamer

• Service– Jabbify

Page 12: Comet: an Overview and a New Solution Called Jabbify

Server Side Issues

• Scaling– Every user = 1 connection

• Complexity– Threading– Learning Curve

Page 13: Comet: an Overview and a New Solution Called Jabbify

What is Jabbify?

• Comet, simplified• No server• No setup• JavaScript API and GET requests

Page 14: Comet: an Overview and a New Solution Called Jabbify

Why Jabbify?

Simple to use

Scale easily

Rapid setup

Page 15: Comet: an Overview and a New Solution Called Jabbify

Simple to usesynchronized (_continuations) { for(Iterator<Map.Entry <String, ArrayList<Continuation>>> iter = _continuations.entrySet().iterator(); iter.hasNext();){ Map.Entry<String, ArrayList<Continuation>> entry = iter.next(); ArrayList<Continuation> continuations = entry.getValue(); for(Continuation c : continuations){ c.resume(); } }_continuations.clear();}

Jabbify.connect({name: this.username}, this.continue_to('after_connect'))after_connect: function(){ Jabbify.send('vote','submit', {result: this.result})}

vs

Page 16: Comet: an Overview and a New Solution Called Jabbify

Scale easily

• Scaling comet >> Scaling traditional web applications

• Resource intensive• Jabbify is built to scale as usage grows

Page 17: Comet: an Overview and a New Solution Called Jabbify

Rapid Setup<New id="cf" class="org.mortbay.jetty.plus.naming.Resource"> <Arg>jms/connectionFactory</Arg> <Arg> <New class="org.apache.activemq.ActiveMQConnectionFactory"> <Arg>failover:(tcp://localhost:61616)?initialReconnectDelay=20&amp;maxReconnectDelay=900</Arg> </New> </Arg></New>

<script language="javascript" type="text/javascript" src="jabbify.js"></script>

vs

Page 18: Comet: an Overview and a New Solution Called Jabbify

Comet is complex• Client

– Transports (JSONP, Window.name, Flash, XHR, iframe)

• Server– Special server– Setup time– Learning curve

• Scaling– Resource consumption– Threading issues

Page 19: Comet: an Overview and a New Solution Called Jabbify

Jabbify is simple• Client to Client Comet

– JavaScript API• Jabbify.send(“message”,”create”,{message: “hi there”});

• Server to Client Comet– GET requests

• https://jabbify.com/message_push?key=123&type=message...

Page 20: Comet: an Overview and a New Solution Called Jabbify

How It Works

Page 21: Comet: an Overview and a New Solution Called Jabbify

Demo

Page 22: Comet: an Overview and a New Solution Called Jabbify

Take Home Points

Comet is coming

Jabbify = easy Comet

Page 23: Comet: an Overview and a New Solution Called Jabbify

Showcase• Jabbify Simple Chat Client• Keyboard Demo• Chat.unwrongest.com