Real Time Communication APIs workshop, Elyran Kogan, Liveperson
Real-time APIs
-
Upload
ross-mason -
Category
Technology
-
view
5.873 -
download
0
description
Transcript of Real-time APIs
![Page 1: Real-time APIs](https://reader035.fdocuments.us/reader035/viewer/2022062300/554fb15fb4c905ad218b5281/html5/thumbnails/1.jpg)
Real-time APIsand how to build one
@rossmason, @mulesoft
![Page 2: Real-time APIs](https://reader035.fdocuments.us/reader035/viewer/2022062300/554fb15fb4c905ad218b5281/html5/thumbnails/2.jpg)
Agenda
• What the heck is Real-time APIs• The technology and trends• Demos
![Page 3: Real-time APIs](https://reader035.fdocuments.us/reader035/viewer/2022062300/554fb15fb4c905ad218b5281/html5/thumbnails/3.jpg)
What is real-time?
• Real-time: the ability to react to something as soon as it happens
• Web real-time: Same but slower (about 900ms delay is ok)
![Page 4: Real-time APIs](https://reader035.fdocuments.us/reader035/viewer/2022062300/554fb15fb4c905ad218b5281/html5/thumbnails/4.jpg)
What is a real-time API?
• Real-time API: Allows an app to only register for events that it is interested in– Give me new customers as they are added– Tell me when the stock price changes– Tell me in 4 weeks to send an email to Bob
![Page 5: Real-time APIs](https://reader035.fdocuments.us/reader035/viewer/2022062300/554fb15fb4c905ad218b5281/html5/thumbnails/5.jpg)
Why Real-time?
• User experience: Don’t make people wait• Accuracy: Don’t make things wait• Because life happen in real-time
![Page 6: Real-time APIs](https://reader035.fdocuments.us/reader035/viewer/2022062300/554fb15fb4c905ad218b5281/html5/thumbnails/6.jpg)
Why Real-time?
Speed
![Page 7: Real-time APIs](https://reader035.fdocuments.us/reader035/viewer/2022062300/554fb15fb4c905ad218b5281/html5/thumbnails/7.jpg)
What do most API consumers do?
• Polling– Make a request every 60 seconds– 61.672% of calls yield no result– New data can be available and waiting for 59.9
seconds– Need to work within the boundaries of API rate
limits • How many calls per hour• Total calls per day• Time between calls
![Page 8: Real-time APIs](https://reader035.fdocuments.us/reader035/viewer/2022062300/554fb15fb4c905ad218b5281/html5/thumbnails/8.jpg)
Why Real-time?
Broadcast
![Page 9: Real-time APIs](https://reader035.fdocuments.us/reader035/viewer/2022062300/554fb15fb4c905ad218b5281/html5/thumbnails/9.jpg)
Why Real-time?
Engagement
![Page 10: Real-time APIs](https://reader035.fdocuments.us/reader035/viewer/2022062300/554fb15fb4c905ad218b5281/html5/thumbnails/10.jpg)
Push vs Streaming
Push (aka WebHooks)• I’ll call you back• Asynchronous• Drawbacks
– Need to have a reply channel setup
– Considered a security risk by some
– Reliability complicated – did the data arrive
Streaming• Keep the line open• Request Response• Drawbacks
– Holds a socket connection open – Continuations can be used
– Harder to implement durable connections
![Page 11: Real-time APIs](https://reader035.fdocuments.us/reader035/viewer/2022062300/554fb15fb4c905ad218b5281/html5/thumbnails/11.jpg)
REST or Real-time?
• Real-time APIs are additive to an existing REST or SOAP API
• Invocation semantics are different– Client needs to handle two invocation models
• Real-time APIs are mostly used to query data– Usually not to perform CRUD operations
• Have different SLA and reliability requirements
![Page 12: Real-time APIs](https://reader035.fdocuments.us/reader035/viewer/2022062300/554fb15fb4c905ad218b5281/html5/thumbnails/12.jpg)
REST API
REST or Real-time?
Resource A Resource B Resource C
Streaming API
Transport
Query Processor
Subscription Manager
consumer
![Page 13: Real-time APIs](https://reader035.fdocuments.us/reader035/viewer/2022062300/554fb15fb4c905ad218b5281/html5/thumbnails/13.jpg)
Real-time Technologies• Transport
– Comet (HTTP)– WebSocket (HTTP)
• Protocols– With formal pub/sub semantics:
• XMPP• Bayeux• STOMP
– Ad hoc, ie "subscription" expressed in the request:• JSON
• Push– PubSubHubbub– Web Hooks
![Page 14: Real-time APIs](https://reader035.fdocuments.us/reader035/viewer/2022062300/554fb15fb4c905ad218b5281/html5/thumbnails/14.jpg)
Real-time APIs are realAPI Real-time technology/protocol
Salesforce Comet
Facebook PubSubHubbub
Instagram Ah Hoc (WebHooks/PubSubHubbub)
Twitter Ad Hoc (Comet)
PubNub Ad Hoc
SuperFeedr XMPP
Pusher Ad Hoc (WebSockets)
![Page 15: Real-time APIs](https://reader035.fdocuments.us/reader035/viewer/2022062300/554fb15fb4c905ad218b5281/html5/thumbnails/15.jpg)
Real-time APIs: REST + JSON or XML
1% of all APIs support real-time interaction
source: ProgrammableWeb.com
![Page 16: Real-time APIs](https://reader035.fdocuments.us/reader035/viewer/2022062300/554fb15fb4c905ad218b5281/html5/thumbnails/16.jpg)
Stop. Demo time!
![Page 17: Real-time APIs](https://reader035.fdocuments.us/reader035/viewer/2022062300/554fb15fb4c905ad218b5281/html5/thumbnails/17.jpg)
Demo 1: AJAX
Streaming API
Transport
Query Processor
Subscription Manager
HTTP Long Polling
CometD
<None>
https://github.com/rossmason/mule-streaming-api-demo
![Page 18: Real-time APIs](https://reader035.fdocuments.us/reader035/viewer/2022062300/554fb15fb4c905ad218b5281/html5/thumbnails/18.jpg)
Demo 2: WebSockets
Streaming API
Transport
Query Processor
Subscription Manager
WebSocket
JMS
Esper
https://github.com/rossmason/mule-streaming-api-demo
![Page 19: Real-time APIs](https://reader035.fdocuments.us/reader035/viewer/2022062300/554fb15fb4c905ad218b5281/html5/thumbnails/19.jpg)
Mule real-time API support
Technologies• CometD• Web Sockets• Ad Hoc• PubSubHubbub• XMPP• STOMP• WebHooks
3rd Party APIs• Salesforce Streaming API• Facebook real-time API• Twitter Firehose• PubNub
![Page 20: Real-time APIs](https://reader035.fdocuments.us/reader035/viewer/2022062300/554fb15fb4c905ad218b5281/html5/thumbnails/20.jpg)
Real-time Web SotN
• Still in early adopter territory– But some major APIs use this approach
• Limitations– No discovery protocol (i.e. WADL)– Many different methods• Some hampered by older browser technology (i.e. Web
Sockets
![Page 21: Real-time APIs](https://reader035.fdocuments.us/reader035/viewer/2022062300/554fb15fb4c905ad218b5281/html5/thumbnails/21.jpg)
Thank You!
• Twitter: @rossmason, @mulesoft
• Slides: http://slideshare.net/rossmason
• Code: https://github.com/rossmason/mule-streaming-api-demo
• Blog: http://blogs.mulesoft.org
• We are hiring: http://mulesoft.com.careers