WebSockets
by Bodo Kaiser
What are WebSockets?
WebSockets allow bidirectional communication over HTTP!
HTTP
Server
Client
GET / HTTP/1.1	
Host: localhost	
Accept: */*
HTTP/1.1 200 OK	
Content-Type: text/plain	
Content-Length:...
WS
Server
Client
GET / HTTP/1.1	
Host: localhost	
Upgrade: websocket	
Connection: Upgrade	
Sec-WebSocket-Key: …	
Sec-WebSo...
Frame Encoding
1000 0001 0000 0101 0100 1000 0110 0101 0111 1001
PayloadHeader
H e y
F
I
N
R
S
V
OP
CODE
M
A
S
K
LENGTH
Ex...
WebSockets in node.js
socket.io by learn boost
fallback support, high level api (e.g. events)
!
ws by einaros
„fastest“ we...
Walve
- socket.io by learn boost
not working, using xhr fallback all the time, cannot read code for PR
!
- other ws implem...
Design
http.Server
„upgrade“ Event
walve.Server
walve.Response
walve.Socket
walve.Socket
walve.Incoming walve.Outgoing
„re...
Code Examples
Visit http://github.com/bodokaiser/node-walve !
!
!
Do not forget to leave a Start :)
Performance (Hello World)
Hello World
0,000
1,000
2,000
3,000
4,000
5,000
ws walve
Performance (Small Image)
Small Image
60,000
70,000
80,000
90,000
100,000
110,000
ws walve
Performance (Large Image)
Large Image
Werteachse
2000,000
2400,000
2800,000
3200,000
3600,000
4000,000
4400,000
4800,000
5...
Performance (Memory Consumption)
Memory Consumption
0,0
100,0
200,0
300,0
400,0
500,0
walve ws
Further Thoughts
1. Reliability
!
2. Extendability
!
3. Future development
!
4. Mobile Usage (ProTip)
Examples
Messenger
!
Simple WebSocket Chat with Image support.
Nearby
!
Realtime Tracking with Google Maps and
Geolocation...
Thanks and Q&A
Follow me on twitter @bodojs
!
Star my projects on github github.com/bodokaiser
Upcoming SlideShare
Loading in …5
×

WebSockets - Today, in the Past, in Future and in Production.

492 views

Published on

In the given talk I cover interesting fact about the protocol which provides HTTP bidirectional communication. Starting with the past state of web sockets and their implementation I explain the protocol step by step, present my own stream based WebSocket implementation and compare it to present challengers. To the end I talk about my personal experience with WebSockets and how I predict the future of them.

Published in: Software, Technology
0 Comments
1 Like
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total views
492
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
5
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

WebSockets - Today, in the Past, in Future and in Production.

  1. 1. WebSockets by Bodo Kaiser
  2. 2. What are WebSockets? WebSockets allow bidirectional communication over HTTP!
  3. 3. HTTP Server Client GET / HTTP/1.1 Host: localhost Accept: */* HTTP/1.1 200 OK Content-Type: text/plain Content-Length: 12
  4. 4. WS Server Client GET / HTTP/1.1 Host: localhost Upgrade: websocket Connection: Upgrade Sec-WebSocket-Key: … Sec-WebSocket-Version:13 HTTP/1.1 101 Switching… Upgrade: websocket Connection: Upgrade Sec-WebSocket-Accept: …
  5. 5. Frame Encoding 1000 0001 0000 0101 0100 1000 0110 0101 0111 1001 PayloadHeader H e y F I N R S V OP CODE M A S K LENGTH Extended Length Masking
  6. 6. WebSockets in node.js socket.io by learn boost fallback support, high level api (e.g. events) ! ws by einaros „fastest“ websocket implementation
  7. 7. Walve - socket.io by learn boost not working, using xhr fallback all the time, cannot read code for PR ! - other ws implementations awful API design, also bad to read 1. Follows node’s core conventions 2. Uses node’s TransformStreams 3. Written in readable JavaScript
  8. 8. Design http.Server „upgrade“ Event walve.Server walve.Response walve.Socket walve.Socket walve.Incoming walve.Outgoing „response“ Event Some Router / Web Framework
  9. 9. Code Examples Visit http://github.com/bodokaiser/node-walve ! ! ! Do not forget to leave a Start :)
  10. 10. Performance (Hello World) Hello World 0,000 1,000 2,000 3,000 4,000 5,000 ws walve
  11. 11. Performance (Small Image) Small Image 60,000 70,000 80,000 90,000 100,000 110,000 ws walve
  12. 12. Performance (Large Image) Large Image Werteachse 2000,000 2400,000 2800,000 3200,000 3600,000 4000,000 4400,000 4800,000 5200,000 5600,000 6000,000 ws walve
  13. 13. Performance (Memory Consumption) Memory Consumption 0,0 100,0 200,0 300,0 400,0 500,0 walve ws
  14. 14. Further Thoughts 1. Reliability ! 2. Extendability ! 3. Future development ! 4. Mobile Usage (ProTip)
  15. 15. Examples Messenger ! Simple WebSocket Chat with Image support. Nearby ! Realtime Tracking with Google Maps and Geolocation. ! http://github.com/bodokaiser/messenger http://github.com/bodokaiser/nearby
  16. 16. Thanks and Q&A Follow me on twitter @bodojs ! Star my projects on github github.com/bodokaiser

×