![Page 1: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/1.jpg)
How to build a scalable SNS via Polling & Push
Kewang
三竹資訊
![Page 2: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/2.jpg)
2
Who I am
● 王慕羣● Java / Node.js / AngularJS● SQL-like / HBase
● Mentor: NIU CSIE
GitHub: kewangtw
Google Play: kewang
Facebook: kewangtw
Linkedin: kewangtw
Slideshare: kewang
Mail: [email protected]
![Page 3: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/3.jpg)
Who Mitake is
三竹資訊
![Page 4: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/4.jpg)
Who Mitake is
三竹資訊
大家都唸 Mitake
![Page 5: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/5.jpg)
Who Mitake is
三竹資訊
大家都唸 Mitake ,但我們公司都唸 Mitake
![Page 6: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/6.jpg)
Who Mitake is
三竹資訊
Mitake 不唸作 MiTAC 啊!!!
![Page 7: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/7.jpg)
Who Mitake is
三竹資訊
![Page 8: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/8.jpg)
Who Mitake is
三竹資訊● 簡訊平台
![Page 9: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/9.jpg)
Who Mitake is
三竹資訊● 簡訊平台● 行動下單:
![Page 10: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/10.jpg)
Who Mitake is
三竹資訊● 簡訊平台● 行動下單:
![Page 11: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/11.jpg)
Who Mitake is
三竹資訊● 簡訊平台● 行動下單:不計其數
![Page 12: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/12.jpg)
Who Mitake is
三竹資訊● 簡訊平台● 行動下單:不計其數● 行動銀行:
![Page 13: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/13.jpg)
Who Mitake is
三竹資訊● 簡訊平台● 行動下單:不計其數● 行動銀行:臺銀、土銀、富邦、台新、聯邦、臺企銀、遠銀、華南、澳盛、郵局、合庫、渣打 ...等 18 家
![Page 14: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/14.jpg)
Who Mitake is
三竹資訊● 簡訊平台● 行動下單:不計其數● 行動銀行:臺銀、土銀、富邦、台新、聯邦、臺企銀、遠銀、華南、澳盛、郵局、合庫、渣打 ...等 18 家● 產壽險:
![Page 15: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/15.jpg)
Who Mitake is
三竹資訊● 簡訊平台● 行動下單:不計其數● 行動銀行:臺銀、土銀、富邦、台新、聯邦、臺企銀、遠銀、華南、澳盛、郵局、合庫、渣打 ...等 18 家● 產壽險:全球、明台、新光、新安東京、富邦 ...等
![Page 16: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/16.jpg)
Who Mitake is
三竹資訊● 簡訊平台● 行動下單:不計其數● 行動銀行:臺銀、土銀、富邦、台新、聯邦、臺企銀、遠銀、華南、澳盛、郵局、合庫、渣打 ... 等
18 家● 產壽險:全球、明台、新光、新安東京、富邦 ... 等● 其他:
![Page 17: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/17.jpg)
Who Mitake is
三竹資訊● 簡訊平台● 行動下單:不計其數● 行動銀行:臺銀、土銀、富邦、台新、聯邦、臺企銀、遠銀、華南、澳盛、郵局、合庫、渣打 ... 等 18家● 產壽險:全球、明台、新光、新安東京、富邦 ... 等● 其他: udn 買東西、手機逛週年慶、財政園地、證交所、綜所稅申報 ... 等
![Page 18: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/18.jpg)
18
System Architecture
![Page 19: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/19.jpg)
19
System Architecture
![Page 20: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/20.jpg)
20
System Architecture (Backend)
![Page 21: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/21.jpg)
21
System Architecture (Backend)
HadoopCon 2014
![Page 22: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/22.jpg)
22
System Architecture (Frontend)
![Page 23: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/23.jpg)
23
Agenda
● Variety of sync mechanisms● Polling & Push● RESTful API Design● API Blueprint
![Page 24: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/24.jpg)
24
Variety of sync mechanisms
![Page 25: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/25.jpg)
25
Variety of sync mechanisms
● Polling● Comet● Long Polling● WebSocket● Engine.IO (Socket.IO)
![Page 26: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/26.jpg)
26
Pollingsend scheduling request
![Page 27: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/27.jpg)
27
Polling
client server
![Page 28: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/28.jpg)
28
Polling
client server
T0T1
T2
![Page 29: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/29.jpg)
29
Polling
client server
T0T1
T2
T4T5
T6
![Page 30: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/30.jpg)
30
Polling
client server
T0T1
T2
T4T5
T6
T8T9
T10
![Page 31: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/31.jpg)
31
Polling
● Pros– Easy to implement
● Cons– No efficiency
![Page 32: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/32.jpg)
32
Cometa never died HTTP request
![Page 33: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/33.jpg)
33
Comet
client server
![Page 34: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/34.jpg)
34
Comet
client server
T0T1
![Page 35: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/35.jpg)
35
Comet
client server
T0T1
![Page 36: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/36.jpg)
36
Comet
client server
T0T1
T3T2
![Page 37: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/37.jpg)
37
Comet
client server
T0T1
T3
T6
T2
T5
![Page 38: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/38.jpg)
38
Comet
client server
T0T1
T3
T6T8
T2
T5T7
![Page 39: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/39.jpg)
39
Comet
client server
T0T1
T3
T6T8
T12
T2
T5T7
T11
![Page 40: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/40.jpg)
40
Comet
● Pros– Save more network traffic
● Cons– Blocking IO issue– Always get server response, can't send another request
![Page 41: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/41.jpg)
41
Long Pollingsend a long time request repeatedly
when response received
![Page 42: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/42.jpg)
42
Long Polling
client server
![Page 43: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/43.jpg)
43
Long Polling
client server
T0T1
![Page 44: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/44.jpg)
44
Long Polling
client server
T0T1
![Page 45: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/45.jpg)
45
Long Polling
client server
T0T1
T4
T3
![Page 46: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/46.jpg)
46
Long Polling
client server
T0T1
T4
T3
T5
![Page 47: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/47.jpg)
47
Long Polling
client server
T0T1
T4
T3
T5
![Page 48: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/48.jpg)
48
Long Polling
client server
T0T1
T4
T3
T5
T21T20
![Page 49: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/49.jpg)
49
Long Polling
● Pros– Save a little network traffic– Can send another request
● Cons– I don't know
![Page 50: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/50.jpg)
50
WebSocketFDX communications channels over a single TCP connection
![Page 51: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/51.jpg)
51
WebSocket
client server
![Page 52: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/52.jpg)
52
WebSocket
client server
![Page 53: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/53.jpg)
53
WebSocket
client server
T0T1
T2
![Page 54: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/54.jpg)
54
WebSocket
client server
T0T1
T2
T3T4
T5
![Page 55: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/55.jpg)
55
WebSocket
client server
T0T1
T2
T3T4
T5T9
T10T11
![Page 56: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/56.jpg)
56
WebSocket
client server
T0T1
T2
T3T4
T5
T17T18
T19
T9T10
T11
![Page 57: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/57.jpg)
57
WebSocket
● Pros– Bidirectional communication– Save more network traffic
● Cons– Proxy & Firewall issue
![Page 58: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/58.jpg)
58
Engine.IOcommunication layer for Socket.IO
![Page 59: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/59.jpg)
59
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 60: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/60.jpg)
60
Engine.IO - Overview
![Page 61: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/61.jpg)
61
Engine.IO - Overview
● Ensure the most reliable realtime communication
![Page 62: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/62.jpg)
62
Engine.IO - Overview
● Ensure the most reliable realtime communication● Always establishes a long-polling connection first
![Page 63: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/63.jpg)
63
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 64: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/64.jpg)
64
Engine.IO - Upgrade transport seamlessly
![Page 65: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/65.jpg)
65
Engine.IO - Upgrade transport seamlessly
● Switches from polling to another transport in between polling cycles
![Page 66: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/66.jpg)
66
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 67: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/67.jpg)
67
Engine.IO
client server
![Page 68: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/68.jpg)
68
Engine.IO
client server
T0T1
![Page 69: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/69.jpg)
69
Engine.IO
client server
T0T1
![Page 70: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/70.jpg)
70
Engine.IO
client server
T0T1
![Page 71: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/71.jpg)
71
Engine.IO
client server
T0T1T6
T5
T7
![Page 72: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/72.jpg)
72
Engine.IO
client server
T0T1
T11
T6T5
T7T10
![Page 73: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/73.jpg)
73
Engine.IO
client server
T0T1
T11
T6T5
T7T10
![Page 74: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/74.jpg)
74
Engine.IO
client server
T0T1
T11
T6
T12T13
T14
T5
T7T10
![Page 75: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/75.jpg)
75
Engine.IO
● Pros– Auto-switch different network scenario
● Cons– Use particular protocol at server & client
![Page 76: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/76.jpg)
76
Polling & Push
![Page 77: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/77.jpg)
77
Why we don't use WebSocket
● Server– Many corporate proxies block WebSocket traffic
● Client– Many personal firewalls and antivirus softwares block
WebSocket traffic
![Page 78: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/78.jpg)
78
Push != Notification
![Page 79: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/79.jpg)
79
Push != Notification
![Page 80: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/80.jpg)
80
Push != NotificationPush Notification
Notification
Push Notification
Notification
![Page 81: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/81.jpg)
81
Push - Overview
● Non-IM– Breaking news notification– Remittance notification– Call off work notification– Email notification– ......etc.
● IM– Message notification
![Page 82: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/82.jpg)
82
How it works?
![Page 83: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/83.jpg)
83
When unsafe APIs done - Server
1.Store affected devices' ID & API ID to database
2.Send Push to affected devices
![Page 84: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/84.jpg)
84
When unsafe APIs done - Client
● Send an unified GET request– GET /datas
![Page 85: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/85.jpg)
85
When unsafe APIs done - Client
● Send an unified GET request– GET /datas
● Push off– apply frequency rapidly to achieve realtime, but waste
resources
![Page 86: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/86.jpg)
86
When unsafe APIs done - Client
● Send an unified GET request– GET /datas
● Push off– apply frequency rapidly to achieve realtime, but waste
resources● Push on
– apply frequency long to save resources– when Push comes, send request to get newest data to
achieve realtime
![Page 87: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/87.jpg)
87
Push - Push off
client server
![Page 88: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/88.jpg)
88
Push - Push off
client server
T0T1
T2
![Page 89: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/89.jpg)
89
Push - Push off
client server
T0T1
T2
T4T5
T6
![Page 90: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/90.jpg)
90
Push - Push off
client server
T0T1
T2
T4T5
T6
T8T9
T10
![Page 91: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/91.jpg)
91
Push - Push on
client server SNS
![Page 92: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/92.jpg)
92
Push - Push on
client server
T0T1
T2
SNS
![Page 93: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/93.jpg)
93
Push - Push on
client server
T0T1
T2
T22T23
T24
SNS
![Page 94: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/94.jpg)
94
Push - Push on
client server
T0T1
T2
T22T23
T24
SNS
T30
![Page 95: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/95.jpg)
95
Push - Push on
client server
T0T1
T2
T22T23
T24
T31T32
T33
SNS
T30
![Page 96: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/96.jpg)
96
Fallback
● Don't polling everything● Every GET APIs provide UI operation
![Page 97: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/97.jpg)
97
Fallback
![Page 98: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/98.jpg)
98
RESTful API design
![Page 99: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/99.jpg)
99
RESTful API Design
● HTTP method● Common examples● Is Graph API RESTful?● Actual example● Internal & Open API
![Page 100: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/100.jpg)
100
GET - Retrieve a resource
● A request to the server should never change the resource state
![Page 101: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/101.jpg)
101
GET - Retrieve a resource
● A request to the server should never change the resource state
● Incidental side effects are OK– Like logging
![Page 102: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/102.jpg)
102
GET - Retrieve a resource
● A request to the server should never change the resource state
● Incidental side effects are OK– Like logging
● Common response code– 200 OK
![Page 103: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/103.jpg)
103
GET - Retrieve a resource
● A request to the server should never change the resource state
● Incidental side effects are OK– Like logging
● Common response code– 200 OK– 301 Moved Permanently
![Page 104: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/104.jpg)
104
GET - Retrieve a resource
● A request to the server should never change the resource state
● Incidental side effects are OK– Like logging
● Common response code– 200 OK– 301 Moved Permanently– 404 Not Found (related to DELETE)– 410 Gone (related to DELETE)
![Page 105: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/105.jpg)
105
DELETE - Remove a resource
● A request to the server should destroy the resource & never refer to it again
![Page 106: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/106.jpg)
106
DELETE - Remove a resource
● A request to the server should destroy the resource & never refer to it again
● Common response code– 200 OK– 202 Accepted– 204 No Content
![Page 107: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/107.jpg)
107
POST
![Page 108: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/108.jpg)
108
POST
● POST-to-append
![Page 109: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/109.jpg)
109
POST
● POST-to-append● Overloaded POST
![Page 110: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/110.jpg)
110
POST-to-append
● A request to the server should create a new resource
![Page 111: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/111.jpg)
111
POST-to-append
● A request to the server should create a new resource
● Common response code– 201 Created
![Page 112: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/112.jpg)
112
POST-to-append
● A request to the server should create a new resource
● Common response code– 201 Created (plus "Location" header)
![Page 113: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/113.jpg)
113
POST-to-append
● A request to the server should create a new resource
● Common response code– 201 Created (plus "Location" header)– 202 Accepted
![Page 114: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/114.jpg)
114
Overloaded POST
● Providing a block of data, such as the result of submitting a form, to a data-handling process
![Page 115: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/115.jpg)
115
Overloaded POST
● Providing a block of data, such as the result of submitting a form, to a data-handling process
● "Data-handling process" can be anything
![Page 116: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/116.jpg)
116
Overloaded POST
● Providing a block of data, such as the result of submitting a form, to a data-handling process
● "Data-handling process" can be anything– POST /users/sort
![Page 117: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/117.jpg)
117
Overloaded POST
● Providing a block of data, such as the result of submitting a form, to a data-handling process
● "Data-handling process" can be anything– POST /users/sort– POST /login
![Page 118: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/118.jpg)
118
Overloaded POST
● Providing a block of data, such as the result of submitting a form, to a data-handling process
● "Data-handling process" can be anything– POST /users/sort– POST /login– ...etc.
![Page 119: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/119.jpg)
119
PUT - Update a resource
● A request to the server should modify the resource
![Page 120: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/120.jpg)
120
PUT - Update a resource
● A request to the server should modify the resource ● Common response code
– 200 OK– 204 No Content
![Page 121: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/121.jpg)
121
Idempotent & Safe
![Page 122: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/122.jpg)
122
Idempotent & Safe
● Idempotent– A HTTP method can be called many times without
different outcomes
![Page 123: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/123.jpg)
123
Idempotent & Safe
● Idempotent– A HTTP method can be called many times without
different outcomes● Safe
– Do not modify resources
![Page 124: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/124.jpg)
124
Idempotent & Safe
Idempotent Safe
GET yes yes
DELETE yes no
POST no no
PUT yes no
![Page 125: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/125.jpg)
125
Common examples
![Page 126: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/126.jpg)
126
GET /users
![Page 127: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/127.jpg)
127
GET /users
● Retrieve all users' brief
![Page 128: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/128.jpg)
128
GET /users
● Retrieve all users' brief{ "users": [ { "name": "kewang", "slogan": "Hello World" }, { "name": "Tony Stark", "slogan": "I'm Iron Man" }, { "name": "America captain", "slogan": "U.S.A." } ]}
![Page 129: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/129.jpg)
129
GET /users/:user_id
![Page 130: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/130.jpg)
130
GET /users/:user_id
● Retrieve a specific user information
![Page 131: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/131.jpg)
131
GET /users/:user_id
● Retrieve a specific user information
{ "name": "kewang", "slogan": "Hello World", "birthday": "19831108", "sex": 0, "email": [ "[email protected]", "[email protected]" ], "company": "mitake"}
![Page 132: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/132.jpg)
132
GET /users/:user_id/avatars
![Page 133: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/133.jpg)
133
GET /users/:user_id/avatars
● Retrieve a specific user's all avatars' URL
![Page 134: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/134.jpg)
134
GET /users/:user_id/avatars
● Retrieve a specific user's all avatars' URL{ "avatars": [ { "url": "http://www.s3.com/abc.png", "created": 1413385358 }, { "url": "http://www.s3.com/def.png", "created": 1401239876 }, { "url": "http://www.s3.com/ghi.png", "created": 1348303844 } ] }
![Page 135: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/135.jpg)
135
GET /users/:user_id/avatar
![Page 136: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/136.jpg)
136
GET /users/:user_id/avatar
● Retrieve a specific user's avatar URL
![Page 137: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/137.jpg)
137
GET /users/:user_id/avatar
● Retrieve a specific user's newest avatar URL
![Page 138: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/138.jpg)
138
GET /users/:user_id/avatar
● Retrieve a specific user's newest avatar URL
{ "url": "http://www.s3.com/abc.png"}
![Page 139: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/139.jpg)
139
Is Graph API RESTful?Facebook powered
![Page 140: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/140.jpg)
140
Graph API - Overview
![Page 141: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/141.jpg)
Graph API - Overview
● Everything is a "node" has a unique ID
![Page 142: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/142.jpg)
142
Graph API - Overview
● Everything is a "node" has a unique ID● Two nodes connect each other with a "edge"
![Page 143: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/143.jpg)
143
Graph API - Overview
● Everything is a "node" has a unique ID● Two nodes connect each other with a "edge"● A node information contains some "fields"
![Page 144: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/144.jpg)
144
Graph API - Are two people friends?
● GET /{user-a-id}/friends/{user-b-id}
![Page 145: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/145.jpg)
145
Graph API - Does someone like a Page?
● GET /{user-id}/likes/{page-id}
![Page 146: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/146.jpg)
146
Graph API - Publishing new Status Updates
● POST /{user-id}/feed● POST /{page-id}/feed
![Page 147: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/147.jpg)
147
Graph API - Uploading Photos
● POST /{user-id}/photos● POST /{page-id}/photos● POST /{album-id}/photos
![Page 148: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/148.jpg)
148
So, Graph API is RESTful?
![Page 150: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/150.jpg)
150
An actual exampleKick a user from system
![Page 151: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/151.jpg)
151
V1 - Kick a user from system
![Page 152: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/152.jpg)
152
V1 - Kick a user from system
● Kick by myself
![Page 153: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/153.jpg)
153
V1 - Kick a user from system
● Kick by myself– DELETE /me
![Page 154: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/154.jpg)
154
V1 - Kick a user from system
● Kick by myself– DELETE /me
● Kick somebody
![Page 155: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/155.jpg)
155
V1 - Kick a user from system
● Kick by myself– DELETE /me
● Kick somebody– DELETE /:user_id
![Page 156: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/156.jpg)
156
V2 - Restore a user to system
![Page 157: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/157.jpg)
157
V2 - Restore a user to system
● PUT /:user_id
![Page 158: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/158.jpg)
158
V2 - Restore a user to system
● PUT /:user_id– Restore somebody to system
![Page 159: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/159.jpg)
159
V2 - Restore a user to system
● PUT /:user_id– Restore somebody to system– Change somebody information
![Page 160: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/160.jpg)
160
V3 - Update a user status
![Page 161: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/161.jpg)
161
V3 - Update a user status
● PUT /:user_id/status
![Page 162: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/162.jpg)
162
V3 - Update a user status
● PUT /:user_id/status– Kick somebody from system
![Page 163: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/163.jpg)
163
V3 - Update a user status
● PUT /:user_id/status– Kick somebody from system– Restore somebody to system
![Page 164: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/164.jpg)
164
Internal & Open API
![Page 165: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/165.jpg)
165
Internal API design guideline
![Page 166: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/166.jpg)
166
Internal API design guideline
● Minimize data size
![Page 167: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/167.jpg)
167
Internal API design guideline
● Minimize data size● Merge operations
![Page 168: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/168.jpg)
168
Internal API design guideline
● Minimize data size● Merge operations● Field names are short & convoluted
![Page 169: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/169.jpg)
169
Internal API design guideline
● Minimize data size● Merge operations● Field names are short & convoluted● Customize request & response for official apps
![Page 170: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/170.jpg)
170
Open API design guideline
![Page 171: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/171.jpg)
171
Open API design guideline
● Minimize data size
![Page 172: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/172.jpg)
172
Open API design guideline
● Minimize data size● Field names are simple & clear
![Page 173: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/173.jpg)
173
Open API design guideline
● Minimize data size● Field names are simple & clear● Build request & response generally
![Page 174: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/174.jpg)
174
Differences - GET /users
Internal API{
"us": [{
"id": "2d3f1a",
"nm": "Kewang",
"el": "[email protected]"
}, {
"id": "9a4f57",
"nm": "Hans",
"el": "[email protected]"
}]
}
Open API
{
"users": [{
"id": "2d3f1a",
"name": "Kewang"
}, {
"id": "9a4f57",
"name": "Hans"
}]
}
![Page 175: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/175.jpg)
175
API Blueprint
![Page 176: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/176.jpg)
176
API Blueprint
● Introduction● Aglio● API-Mock● Postman
![Page 177: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/177.jpg)
177
Introduction
● Web API Language● Pure Markdown● Design for Humans● Understandable by Machines● Powerful Tooling● Easy Lifecycle
![Page 178: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/178.jpg)
178
Hello World
![Page 179: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/179.jpg)
179
Complex example
![Page 180: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/180.jpg)
180
Aglio - API Blueprint renderer
![Page 181: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/181.jpg)
181
Aglio - Complex example
![Page 182: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/182.jpg)
182
API-Mock & Postman
![Page 183: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/183.jpg)
183
Live DEMO
![Page 184: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/184.jpg)
184
References
![Page 185: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/185.jpg)
185
References
![Page 186: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/186.jpg)
186
References
● Browser 與 Server 持續同步的作法介紹● Comet (programming)● Engine.IO: the realtime engine● Engine.IO Protocol● API Design Optimized for Mobile Platform● HTTP GET with request body● Does Google treat 404 and 410 status code differen
tly
![Page 187: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/187.jpg)
187
![Page 188: How to build a scalable SNS via Polling & Push](https://reader031.vdocuments.pub/reader031/viewer/2022020306/547e8592b37959532b8b54c1/html5/thumbnails/188.jpg)
188