real time web: is there a life without socket.io and node.js?

54
Real-time web IS THERE A LIFE WITHOUT SOCKET.IO AND NODE.JS?

Upload: eduard-trayan

Post on 27-May-2015

985 views

Category:

Internet


1 download

DESCRIPTION

A small overview of possible solutions for making real-time web in context of client (server is a black box)

TRANSCRIPT

Page 1: Real time web: is there a life without socket.io and node.js?

Real-time webIS THERE A LIFE WITHOUT SOCKET.IO AND NODE.JS?

Page 2: Real time web: is there a life without socket.io and node.js?

2

Who am I Eduard Trayan Software developer at EPAM Systems Zend PHP 5.3 Certified developer SensioLabs Certified Symfony Developer [email protected]

Page 3: Real time web: is there a life without socket.io and node.js?

3

Agenda Say some words about real-time web Do small overview about possible solutions And play game

Page 4: Real time web: is there a life without socket.io and node.js?

4

Real-time web

Page 5: Real time web: is there a life without socket.io and node.js?

5

What is the real-time web?

Page 6: Real time web: is there a life without socket.io and node.js?

6

Real-time web Set of technologies and practices Receiving information as soon as possible Users doesn't need to check updates http://en.wikipedia.org/wiki/Real-time_web

Page 7: Real time web: is there a life without socket.io and node.js?

7

Main principles – push instead of pull

Page 8: Real time web: is there a life without socket.io and node.js?

8

Main principles – ASAP

Page 9: Real time web: is there a life without socket.io and node.js?

9

Where to find a use?

Page 10: Real time web: is there a life without socket.io and node.js?

10

Where to find a use?

Page 11: Real time web: is there a life without socket.io and node.js?

11

Solutions

Page 12: Real time web: is there a life without socket.io and node.js?

12

Possible solutions

Proprietary solutions

Comet

Ajax polling

WebSockets

Page 13: Real time web: is there a life without socket.io and node.js?

13

Proprietary solutions

Page 14: Real time web: is there a life without socket.io and node.js?

14

Proprietary solutions

Adobe Flash

Java applet

Microsoft Silverlight

Page 15: Real time web: is there a life without socket.io and node.js?

15

Comet

Page 16: Real time web: is there a life without socket.io and node.js?

16

What is the comet?

Page 17: Real time web: is there a life without socket.io and node.js?

17

Comet is not a cleaner

Page 18: Real time web: is there a life without socket.io and node.js?

18

Comet is not a solar system body

Page 19: Real time web: is there a life without socket.io and node.js?

19

Comet Web application model Long-held HTTP requests Server push datahttp://en.wikipedia.org/wiki/Comet_(programming)

Page 20: Real time web: is there a life without socket.io and node.js?

20

CometAjax long pollingForever iframeActiveXObject htmlfileServer sent eventsXMLHTTPRequest interactive stateJSONP long polling

Page 21: Real time web: is there a life without socket.io and node.js?

21

Ajax long polling - algorithm

Page 22: Real time web: is there a life without socket.io and node.js?

22

Ajax long polling - opportunities

Cross-domain requests

Unidirectional communications between client and server

Binary or text data

Or the same opportunities as provided by XMLHTTPRequest

Page 23: Real time web: is there a life without socket.io and node.js?

23

Ajax long polling - disadvantagesBig delay between event and notification

Big number of requests

Big incoming traffic

Caching by browsers

Possible problems with proxy

Page 24: Real time web: is there a life without socket.io and node.js?

24

What solution does facebook use for chat?

1. Ajax long polling2. WebSockets3. Forever iframe4. Proprietary solutions

Page 25: Real time web: is there a life without socket.io and node.js?

25

Forever iframe - algorithm

Page 26: Real time web: is there a life without socket.io and node.js?

26

Forever iframe - opportunities

Cross-domain requests

POST requests

Unidirectional communications between client and server

Page 27: Real time web: is there a life without socket.io and node.js?

27

Forever iframe - disadvantagesLoad indication

Script buffering

Page buffering

Proxy buffering

Impossible to compress data

Changes in browser’s history

Hard to detect disconnections/errors

Page 28: Real time web: is there a life without socket.io and node.js?

28

What solution does vk.com use for chat?1. WebSockets2. JSONP long polling3. Ajax long polling4. Proprietary solutions

Page 29: Real time web: is there a life without socket.io and node.js?

29

ActiveXObject - algorithm

Page 30: Real time web: is there a life without socket.io and node.js?

30

ActiveXObject - opportunities

Cross-domain requests

POST requests

Unidirectional communications between client and server

Page 31: Real time web: is there a life without socket.io and node.js?

31

ActiveXObject - disadvantagesIE only

Script buffering

Page buffering

Proxy buffering

Impossible to compress data

Changes in browser’s history

Hard to detect disconnections/errors

Page 32: Real time web: is there a life without socket.io and node.js?

32

What solution does vseti.by use for chat?1. Forever iframe2. Proprietary solutions3. ActiveXObject htmlfile4. Ajax long polling

Page 33: Real time web: is there a life without socket.io and node.js?

33

SSE - algorithm

Page 34: Real time web: is there a life without socket.io and node.js?

34

SSE - opportunitiesMultiline messages

Cross-domain requests

Unidirectional communications between client and server

Custom events

Automatic reconnect

Error handling

Control of events

Page 35: Real time web: is there a life without socket.io and node.js?

35

SSE - disadvantagesDoesn’t work in IE

Doesn’t work in android browsers <4.4

Impossible to compress data

Page 36: Real time web: is there a life without socket.io and node.js?

36

What solution does assistent.by use?1. Forever iframe2. Proprietary solutions3. ActiveXObject htmlfile4. Ajax long polling

Page 37: Real time web: is there a life without socket.io and node.js?

37

XMLHTTPRequest interactive state -algorithm

Page 38: Real time web: is there a life without socket.io and node.js?

38

XMLHTTPRequest interactive state -opportunitiesCross-domain requests

Unidirectional communications between client and server

Binary or text data

Or the same opportunities as provided by XMLHTTPRequest

Page 39: Real time web: is there a life without socket.io and node.js?

39

XMLHTTPRequest interactive state -disadvantages

Doesn’t work at <IE10

Unsupported by mobile browsers

Impossible to compress data

Page 40: Real time web: is there a life without socket.io and node.js?

40

What solution does flowdock use for chat?1. Forever iframe2. Proprietary solutions3. WebSockets4. Ajax long polling

Page 41: Real time web: is there a life without socket.io and node.js?

41

JSONP long polling - algorithm

Page 42: Real time web: is there a life without socket.io and node.js?

42

JSONP long polling - opportunities

Cross-domain requests

Unidirectional communications between client and server

Page 43: Real time web: is there a life without socket.io and node.js?

43

JSONP long polling - specifics

Handling errors with callback/onload/onerror/onreadystatechange

Sending callback name in request

Page 44: Real time web: is there a life without socket.io and node.js?

44

JSONP long polling - disadvantagesBig delay between event and notification

Big number of requests

Big incoming traffic

Page 45: Real time web: is there a life without socket.io and node.js?

45

Ajax polling

Page 46: Real time web: is there a life without socket.io and node.js?

46

Ajax polling - algorithm

Page 47: Real time web: is there a life without socket.io and node.js?

47

Ajax polling - opportunities

Cross-domain requests

Unidirectional communications between client and server

Binary or text data

Or the same opportunities as provided in XMLHTTPRequest

Page 48: Real time web: is there a life without socket.io and node.js?

48

Ajax polling - disadvantagesBig delay between event and notification

Big number of requests

Big incoming traffic

Caching by browsers

Page 49: Real time web: is there a life without socket.io and node.js?

49

WebSockets

Page 50: Real time web: is there a life without socket.io and node.js?

50

WebSocket - algorithm

Page 51: Real time web: is there a life without socket.io and node.js?

51

WebSocket - opportunities

Bidirectional communications between client and server

Cross-domain requests

Binary or text data

Usage of extensions and subprotocols

Page 52: Real time web: is there a life without socket.io and node.js?

52

WebSocket - disadvantagesDoesn’t work at <IE10, android browsers <4.4, iOS Safary <6.0, Safary <6

Possible problems with proxy

Page 53: Real time web: is there a life without socket.io and node.js?

53

Useful tools

http://caniuse.com/

http://crossbrowsertesting.com/

http://www.browserstack.com/

Page 54: Real time web: is there a life without socket.io and node.js?

54

Questions?