+ All Categories
Home > Technology > Firebase introduction

Firebase introduction

Date post: 25-Jun-2015
Category:
Upload: mu-chun-wang
View: 280 times
Download: 7 times
Share this document with a friend
Popular Tags:
84
Firebase introduction Kewang
Transcript
Page 1: Firebase introduction

Firebase introduction

Kewang

Page 2: Firebase introduction

2

Live DEMO

https://db.tt/40igKVhc

Page 3: Firebase introduction

3

Agenda

● Variety of sync mechanisms● Firebase

Page 4: Firebase introduction

4

Variety of sync mechanisms

Page 5: Firebase introduction

5

Variety of sync mechanisms

● Polling● Comet● Long Polling● WebSocket● Engine.IO (Socket.IO)● Polling & Push

Page 6: Firebase introduction

6

Pollingsend scheduling request

Page 7: Firebase introduction

7

Polling

client server

Page 8: Firebase introduction

8

Polling

client server

T0T1

T2

Page 9: Firebase introduction

9

Polling

client server

T0T1

T2

T4T5

T6

Page 10: Firebase introduction

10

Polling

client server

T0T1

T2

T4T5

T6

T8T9

T10

Page 11: Firebase introduction

11

Polling

● Pros– Easy to implement

● Cons– No efficiency

Page 12: Firebase introduction

12

Cometa never died HTTP request

Page 13: Firebase introduction

13

Comet

client server

Page 14: Firebase introduction

14

Comet

client server

T0T1

Page 15: Firebase introduction

15

Comet

client server

T0T1

Page 16: Firebase introduction

16

Comet

client server

T0T1

T3T2

Page 17: Firebase introduction

17

Comet

client server

T0T1

T3

T6

T2

T5

Page 18: Firebase introduction

18

Comet

client server

T0T1

T3

T6T8

T2

T5T7

Page 19: Firebase introduction

19

Comet

client server

T0T1

T3

T6T8

T12

T2

T5T7

T11

Page 20: Firebase introduction

20

Comet

● Pros– Save more network traffic

● Cons– Blocking IO issue– Always get server response, can't send another request

Page 21: Firebase introduction

21

Long Pollingsend a long time request repeatedly

when response received

Page 22: Firebase introduction

22

Long Polling

client server

Page 23: Firebase introduction

23

Long Polling

client server

T0T1

Page 24: Firebase introduction

24

Long Polling

client server

T0T1

Page 25: Firebase introduction

25

Long Polling

client server

T0T1

T4

T3

Page 26: Firebase introduction

26

Long Polling

client server

T0T1

T4

T3

T5

Page 27: Firebase introduction

27

Long Polling

client server

T0T1

T4

T3

T5

Page 28: Firebase introduction

28

Long Polling

client server

T0T1

T4

T3

T5

T21T20

Page 29: Firebase introduction

29

Long Polling

● Pros– Save a little network traffic– Can send another request

● Cons– I don't know

Page 30: Firebase introduction

30

WebSocketFDX communications channels over a single TCP connection

Page 31: Firebase introduction

31

WebSocket

client server

Page 32: Firebase introduction

32

WebSocket

client server

Page 33: Firebase introduction

33

WebSocket

client server

T0T1

T2

Page 34: Firebase introduction

34

WebSocket

client server

T0T1

T2

T3T4

T5

Page 35: Firebase introduction

35

WebSocket

client server

T0T1

T2

T3T4

T5T9

T10T11

Page 36: Firebase introduction

36

WebSocket

client server

T0T1

T2

T3T4

T5

T17T18

T19

T9T10

T11

Page 37: Firebase introduction

37

WebSocket

● Pros– Bidirectional communication– Save more network traffic

● Cons– Proxy & Firewall issue

Page 38: Firebase introduction

38

Engine.IOcommunication layer for Socket.IO

Page 39: Firebase introduction

39

Engine.IO - Socket.IO history0.1~0.6.2 0.6.3~0.6.17 0.7.0~0.9.17 1.0.0~now

websocket ✓ ✓ ✓ ✓server-events ✓flashsocket ✓ ✓ ✓

htmlfile ✓ ✓xhr-multipart ✓ ✓xhr-polling ✓ ✓ ✓

jsonp-polling ✓polling ✓

Page 40: Firebase introduction

40

Engine.IO - Overview

Page 41: Firebase introduction

41

Engine.IO - Overview

● Ensure the most reliable realtime communication

Page 42: Firebase introduction

42

Engine.IO - Overview

● Ensure the most reliable realtime communication● Always establishes a long-polling connection first

Page 43: Firebase introduction

43

Engine.IO - Overview

● Ensure the most reliable realtime communication● Always establishes a long-polling connection first

– then tries to upgrade to better transports that are "tested" on the side

Page 44: Firebase introduction

44

Engine.IO - Upgrade transport seamlessly

Page 45: Firebase introduction

45

Engine.IO - Upgrade transport seamlessly

● Switches from polling to another transport in between polling cycles

Page 46: Firebase introduction

46

Engine.IO - Upgrade transport seamlessly

● Switches from polling to another transport in between polling cycles

● To ensure no messages are lost, the upgrade packet will only be sent once all the buffers of the existing transport are flushed and the transport is considered paused

Page 47: Firebase introduction

47

Engine.IO

client server

Page 48: Firebase introduction

48

Engine.IO

client server

T0T1

Page 49: Firebase introduction

49

Engine.IO

client server

T0T1

Page 50: Firebase introduction

50

Engine.IO

client server

T0T1

Page 51: Firebase introduction

51

Engine.IO

client server

T0T1T6

T5

T7

Page 52: Firebase introduction

52

Engine.IO

client server

T0T1

T11

T6T5

T7T10

Page 53: Firebase introduction

53

Engine.IO

client server

T0T1

T11

T6T5

T7T10

Page 54: Firebase introduction

54

Engine.IO

client server

T0T1

T11

T6

T12T13

T14

T5

T7T10

Page 55: Firebase introduction

55

Engine.IO

● Pros– Auto-switch different network scenario

● Cons– Use particular protocol at server & client

Page 56: Firebase introduction

56

Polling & Pushsimple sync mechanism

Page 57: Firebase introduction

57

Polling & Push - Push off

client server

Page 58: Firebase introduction

58

Polling & Push - Push off

client server

T0T1

T2

Page 59: Firebase introduction

59

Polling & Push - Push off

client server

T0T1

T2

T4T5

T6

Page 60: Firebase introduction

60

Polling & Push - Push off

client server

T0T1

T2

T4T5

T6

T8T9

T10

Page 61: Firebase introduction

61

Polling & Push - Push on

client server SNS

Page 62: Firebase introduction

62

Polling & Push - Push on

client server

T0T1

T2

SNS

Page 63: Firebase introduction

63

Polling & Push - Push on

client server

T0T1

T2

T22T23

T24

SNS

Page 64: Firebase introduction

64

Polling & Push - Push on

client server

T0T1

T2

T22T23

T24

SNS

T30

Page 65: Firebase introduction

65

Polling & Push - Push on

client server

T0T1

T2

T22T23

T24

T31T32

T33

SNS

T30

Page 66: Firebase introduction

66

Polling & Push

● Pros– Easy to implement

● Cons– No (official statement)

Page 67: Firebase introduction

67

Firebase

Page 68: Firebase introduction

68

Firebase

● Save data in the cloud● Realtime Data● Easy authentication● Bulletproof Security● Instant Scalability

Page 69: Firebase introduction

69

Pattern 1 - Client Only

Page 70: Firebase introduction

70

Pattern 1 - Client Only

● Developing a brand new application● Needs minimal integration with legacy systems or

other third party services● App doesn’t have heavy data processing needs or

complex user authentication requirements

Page 71: Firebase introduction

71

Pattern 2 - Client & Server

Page 72: Firebase introduction

72

Pattern 2 - Client & Server

● To integrate with third party APIs● Advanced authentication requirements● Can’t run computationally intensive code on a

client, or requires code to run on a trusted server

Page 73: Firebase introduction

73

Pattern 3 - Existing App

Page 74: Firebase introduction

74

Pattern 3 - Existing App

● An existing full-featured app, and aren’t planning a rewrite

● Codebase is large and cannot change● Add realtime features without touching the rest of

app

Page 75: Firebase introduction

75

Live DEMO2

Page 76: Firebase introduction

76

FAQ

Page 77: Firebase introduction

77

FAQ

● Enterprise solution

Page 78: Firebase introduction

78

FAQ

● Enterprise solution– Custom SLA– 24*7 support– Dedicated clusters– Training

Page 79: Firebase introduction

79

FAQ

● Enterprise solution– Custom SLA– 24*7 support– Dedicated clusters– Training

● Concurrent connection

Page 80: Firebase introduction

80

FAQ

● Enterprise solution– Custom SLA– 24*7 support– Dedicated clusters– Training

● Concurrent connection– Free plan has 50 max connections, otherwise is

unlimited

Page 81: Firebase introduction

81

FAQ

● Enterprise solution– Custom SLA– 24*7 support– Dedicated clusters– Training

● Concurrent connection– Free plan has 50 max connections, otherwise is

unlimited● Lock-in

Page 82: Firebase introduction

82

FAQ

● Enterprise solution– Custom SLA– 24*7 support– Dedicated clusters– Training

● Concurrent connection– Free plan has 50 max connections, otherwise is unlimited

● Lock-in– Export data to JSON

Page 83: Firebase introduction

83

References

● Browser 與 Server 持續同步的作法介紹● Comet (programming)● Engine.IO: the realtime engine● Engine.IO Protocol● How Firebase Works● Firebase Callbacks - what's the underlying trigger?● Firebase under the hood - watching web sockets in

Chrome Developer Tools

Page 84: Firebase introduction

84


Recommended