websockets on fire

41
WebSockets On Fire HTML5 WebCamps 2011

Upload: jef-claes

Post on 17-May-2015

3.750 views

Category:

Technology


0 download

DESCRIPTION

HTML5 WebCamps talk on WebSockets

TRANSCRIPT

Page 1: WebSockets On Fire

WebSockets On FireHTML5 WebCamps 2011

Page 2: WebSockets On Fire

Whois

Jef ClaesFerranti Computer Systems

@JefClaeshttp://[email protected]

Page 3: WebSockets On Fire

Content

WHY do we need WebSockets?

WHAT are WebSockets?

What is the state of WebSockets TODAY?

So show me some CODE.

Page 4: WebSockets On Fire

Content

WHY do we need WebSockets?

WHAT are WebSockets?

What is the state of WebSockets TODAY?

So show me some CODE.

Page 5: WebSockets On Fire

DIRECT COMMUNICATION between browser and

server

Page 6: WebSockets On Fire

Chat applications

Page 7: WebSockets On Fire

Collaborative tools

Page 8: WebSockets On Fire

Social networking

Page 9: WebSockets On Fire

Online gaming

Page 10: WebSockets On Fire

But haven’t we been doing this for a while?

Page 11: WebSockets On Fire

COMET

Page 12: WebSockets On Fire

1. Frequent polling

Page 13: WebSockets On Fire

Browser Server

HTTP Request

HTTP Response

Page 14: WebSockets On Fire

GET /PollingStock//PollingStock HTTP/1.1Host: localhost:8080User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.5) Gecko/20091102 Firefox/3.5.5Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8Accept-Language: en-usAccept-Encoding: gzip,deflateAccept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7Keep-Alive: 300Connection: keep-aliveReferer: http://www.example.com/PollingStock/Cookie: showInheritedConstant=false; showInheritedProtectedConstant=false; showInheritedProperty=false; showInheritedProtectedProperty=false; showInheritedMethod=false; showInheritedProtectedMethod=false; showInheritedEvent=false; showInheritedStyle=false; showInheritedEffect=false

HTTP/1.x 200 OKX-Powered-By: Servlet/2.5Server: Sun Java System Application Server 9.1_02Content-Type: text/html;charset=UTF-8

Page 15: WebSockets On Fire

Request / Response headers = 871 bytes1000 clients poll every 10 seconds

1000 * 871 bytes = 0,8MB / 10 seconds

0,8 MB * 6 = 4,8 MB / minute

4,8 MB * 60 = 288 MB / hour

288 MB * 24 = 6,912 GB /

day

Page 16: WebSockets On Fire

2. Long polling

Page 17: WebSockets On Fire

Wait for it...

Browser Server

HTTP Request

HTTP Response

Page 18: WebSockets On Fire

Say NO to COMET

Page 19: WebSockets On Fire

Content

WHY do we need WebSockets?

WHAT are WebSockets?

What is the state of WebSockets TODAY?

So show me some CODE.

Page 20: WebSockets On Fire

‘TCP for the Web’

Full-duplex direct communication

Page 21: WebSockets On Fire

Browser Server

HTTP

HTTP

WebSocket

WebSocket

Page 22: WebSockets On Fire

WebSockets HandshakeGET /demo HTTP/1.1 Upgrade: WebSocket Connection: Upgrade Host: example.com Origin: http://example.com Sec-WebSocket-Key1: 4 @1 46546xW%0l 1 5 Sec-WebSocket-Key2: 12998 5 Y3 1 .P00 ^n:ds[4U

HTTP/1.1 101 WebSocket Protocol Handshake Upgrade: WebSocket Connection: Upgrade Sec-WebSocket-Origin: http://example.com Sec-WebSocket-Location: ws://example.com/demo Sec-WebSocket-Protocol: sample 8jKS'y:G*Co,Wxa-

Page 23: WebSockets On Fire

WebSockets message

0x00 wsMessage 0xFF

Page 24: WebSockets On Fire

Benefits

• Native implemented• Less throughput• Performance• Complexity

Page 25: WebSockets On Fire

Content

WHY do we need WebSockets?

WHAT are WebSockets?

What is the state of WebSockets TODAY?

So show me some CODE.

Page 26: WebSockets On Fire

1. HTML5

Work In Progress

Page 27: WebSockets On Fire

2. Browser support

IE9: NoSafari 5, Chrome 10:YesFireFox 4, Opera 11: Yes, but…

Mobile: No, only Safari :-(

Source: http://caniuse.com

Page 28: WebSockets On Fire

2. Browser support

ALTERNATIVES yesssss

- Silverlight - Flash

Page 29: WebSockets On Fire

3. The server

HTML5 Labs (WCF)http://

html5labs.interoperabilitybridges.com pywebsocket (Apache extension) http://code.google.com/p/pywebsocket/

jWebSocket (Java)http://jwebsocket.org/

web-socket-ruby (Ruby)https://github.com/gimite/web-socket-ruby

Page 30: WebSockets On Fire

Content

WHY do we need WebSockets?

WHAT are WebSockets?

What is the state of WebSockets TODAY?

So show me some CODE.

Page 31: WebSockets On Fire

Why?

Information ASAP

Page 32: WebSockets On Fire

• Information screens• Paging• JIT Printing

• Websites

Why?

Page 33: WebSockets On Fire

1. NetViewer

Page 34: WebSockets On Fire

2. Current Incidents

Page 35: WebSockets On Fire

WCF WebSockets

Server

Dispatcher

Silverlight client

Silverlight client

Silverlight client

http://html5labs.interoperabilitybridges.com/

Page 36: WebSockets On Fire

Code

Page 37: WebSockets On Fire

Conclusion

WebSockets > COMETNot quite ready

Page 38: WebSockets On Fire

Recommended resources

• http://dev.w3.org/html5/websockets/• http://

html5labs.interoperabilitybridges.com

• http://blogs.msdn.com/b/interoperability/archive/tags/html5/

• http://jclaes.blogspot.com

Page 39: WebSockets On Fire

Q & A

Page 40: WebSockets On Fire

Join us

• Twitter:– @MSDNBelux– Our tag today: #webcampbe

• Facebook: – MSDN België (NL)– MSDN BeLux (FR)

• Latest news on www.msdn.be • Always up to date: register to MSDN Flash

and Express Yourself http://www.msdn-newsletters.be

Page 41: WebSockets On Fire

Thank you