WEBSOCKETS AND WEBWORKERS
FOR LOW LATENCY INTERACTIVE WEB APPLICATIONS
WEBSOCKETS
AGENDA
lInteractive Web Applications
lProblems
lEarlier Techniques
lPolling
lLong Polling
lStreaming
lHTML5 Web Sockets
lHow Web Sockets work
lComparison of Polling vs Web Socket
lSupport Chart
lEvent Looping in JavaScript
lNon Blocking Threads
lWeb Workers
INTERACTIVE WEB APPLICATIONS
PROBLEMS
lLow latency
lTime
lCost
lContinuos data traffic
l1 way communication
EARLIER TECHNIQUES
lPolling
lLong Polling
lStreaming
POLLING
LONG POLLING
STREAMING
HTML5 WEBSOCKETS
lFull Duplex Bidirectional Communication
lScalable
lReal Time
lNo Overhead
lReduced Complexity
lUpgrades to the WebSocket Protocol
HOW IT WORKS
WEBSOCKETS SYNTAX
lvar Socket = new WebSocket(url, [protocal] );
lATTRIBUTES
lSocket.readyState
lSocket.bufferedAmount
EVENTS
lOpen
lMessage
lError
lClose
METHODS
lSocket.send()
lSocket.close()
POLLING vs WEBSOCKETS
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 1 second:
Network throughput is (871 x 100,000) = 87,100,000 bytes = 696,800,000 bits per second (665
Mbps)
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)
POLLING vs WEBSOCKETS
SUPPORT CHART
DEMO
WEBWORKERS
EVENT LOOPING IN JAVASCRIPT
NON BLOCKING THREADS
WEB WORKERS
DEMO
QUESTIONS
THANK YOU

WEBSOCKETS AND WEBWORKERS