Share
Embed
Transcript
36 slides
-
Adding realtime to your API [email protected] About me 䡧 Fanout
䡧 Livefyre CTO 䡧 XMPP contributor 䡧 Keywords: realtime, network protocols, federation, open standards -
Adding realtime to your API [email protected] Topics 䡧 What is
a realtime API? 䡧 Challenges 䡧 A new architecture 䡧 Demo -
Adding realtime to your API [email protected] What is realtime? 䡧
“Push” data to recipients 䡧 News, fintech, collaboration, chat, dispatch, games, etc. 䡧 Near-realtime -
Adding realtime to your API [email protected] Does my API need
to be realtime? 䡧 Users expect realtime experiences 䡧 Realtime apps depend on realtime APIs 䡧 Polling sucks 䡧 So…. yes -
Adding realtime to your API [email protected] “A Post HTTP World”
? 䡧 Don’t worry, most realtime APIs today are HTTP-based. 䡧 There are new protocols, but it’s going to be a long transition. 䡧 Also, HTTP/2 may address most issues. -
Adding realtime to your API [email protected] Common realtime push mechanisms
䡧 HTTP streaming 䡧 HTTP long-polling 䡧 Webhooks (HTTP callbacks) 䡧 WebSockets -
Adding realtime to your API [email protected] HTTP streaming 䡧 Response
with indefinite length 䡧 Content usually line-delimited text 䡧 Usually JSON or Server-Sent Events (SSE) -
Adding realtime to your API [email protected] GET /1.1/statuses/sample.json HTTP/1.1 Host:
stream.twitter.com Authorization: OAuth […] HTTP streaming -
Adding realtime to your API [email protected] HTTP/1.1 200 OK connection:
close content-type: application/json date: Fri, 17 Apr 2015 00:32:07 GMT server: tsa transfer-encoding: chunked x-connection-hash: 6028cbda…6f0443a6 {"created_at":"Fri Apr 17 00:32:06 +0000 2015”,"id": 588862464202297345,”text":"tweet 1", … } {"created_at":"Fri Apr 17 00:32:07 +0000 2015”,"id": 588862468392255488,"text":"tweet 2", … } … HTTP streaming -
Adding realtime to your API [email protected] Immature ecosystem 䡧 Most
tools are end-to-end 䡧 Little interoperability 䡧 Realtime APIs tend to be custom-built -
Adding realtime to your API [email protected] Custom-built realtime push 䡧
Event-driven frameworks 䡧 Complex code 䡧 Separate codebase from the non-realtime parts 䡧 Specific to vendor/application -
Adding realtime to your API [email protected] Pull has it right
Client Client Client Caching / CDN API Management Backend API + directives API -
Adding realtime to your API [email protected] Let’s make Push awesome
as Pull 䡧 Separate API design, engineering, operations 䡧 Interoperable / standardized components 䡧 Reference implementation: Pushpin 䡧 Proxy server with realtime magic 䡧 Open source -
Adding realtime to your API [email protected] Pushpin philosophy API Server
GET /stream open integration protocol -
Adding realtime to your API [email protected] Pushpin philosophy Client API
Server GET /stream open integration protocol -
Adding realtime to your API [email protected] Pushpin philosophy Client API
Server GET /stream open integration protocol -
Adding realtime to your API [email protected] Generic Realtime Intermediary Protocol
(GRIP) 䡧 Common protocol between edge and backend 䡧 Engineering targets GRIP 䡧 DevOps manages the edge tier however they want 䡧 Client protocol agnostic -
Adding realtime to your API [email protected] GRIP flow Client API
Server HTTP request -
Adding realtime to your API [email protected] GRIP flow Client API
Server HTTP request HTTP request (forwarded) -
Adding realtime to your API [email protected] GRIP flow Client API
Server HTTP request HTTP request (forwarded) instructions response -
Adding realtime to your API [email protected] GRIP flow Client API
Server HTTP request (hold for updates) -
Adding realtime to your API [email protected] GRIP flow Client API
Server HTTP request push payload -
Adding realtime to your API [email protected] GRIP flow Client API
Server HTTP request push payload HTTP response (realtime push) -
Adding realtime to your API [email protected] Real world example 䡧
LaunchDarkly 䡧 Continuous delivery platform 䡧 Feature flags with controlled rollouts 䡧 Feature checks don’t require contact with LaunchDarkly -
Adding realtime to your API [email protected] Real world example LD
Agent API Backend App Client App Server A LaunchDarkly customer’s web service LaunchDarkly API service GET /page config sync (config cache) -
Adding realtime to your API [email protected] Example project: TodoMVC 䡧
http://todomvc.pushpin.org/ 䡧 To-do list demo with realtime collaboration 䡧 Built with React, Pushpin, Django, Redis 䡧 API documented with Apiary -
Adding realtime to your API [email protected] Thanks! 䡧 Tell us
about realtime apps you’re building 䡧 Check out the project: http://pushpin.org