going real me
play

Going Real-,me: How to Build a Streaming API - PowerPoint PPT Presentation

Going Real-,me: How to Build a Streaming API @rossmason, @muleso= About Me Agenda What the heck is Real-,me APIs The


  1. Going ¡Real-­‑,me: ¡ How ¡to ¡Build ¡a ¡Streaming ¡API ¡ ¡ @rossmason, ¡@muleso= ¡ ¡ ¡ ¡

  2. About ¡Me ¡

  3. Agenda ¡ • What ¡the ¡heck ¡is ¡Real-­‑,me ¡APIs ¡ • The ¡technology ¡and ¡trends ¡ • Demos ¡

  4. What ¡is ¡real-­‑,me? ¡ • Real-­‑,me: ¡the ¡ability ¡to ¡react ¡to ¡something ¡as ¡ soon ¡as ¡it ¡happens ¡ • Web ¡real-­‑,me: ¡Same ¡but ¡slower ¡(about ¡ 900ms ¡delay ¡is ¡ok) ¡

  5. What ¡is ¡a ¡real-­‑,me ¡API? ¡ • Real-­‑,me ¡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 ¡

  6. Why ¡Real-­‑,me? ¡ • User ¡experience: ¡Don’t ¡make ¡ people ¡wait ¡ • Accuracy: ¡Don’t ¡make ¡ things ¡wait ¡ • Because ¡life ¡happen ¡in ¡real-­‑,me ¡ ¡

  7. Why ¡Real-­‑,me? ¡ Speed ¡

  8. 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 ¡wai,ng ¡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 ¡

  9. Why ¡Real-­‑,me? ¡ Broadcast ¡

  10. Why ¡Real-­‑,me? ¡ Engagement ¡

  11. Push ¡vs ¡Streaming ¡ Push ¡(aka ¡WebHooks) ¡ Streaming ¡ • I’ll ¡call ¡you ¡back ¡ • Keep ¡the ¡line ¡open ¡ • Asynchronous ¡ • Request ¡Response ¡ • Drawbacks ¡ • Drawbacks ¡ – Need ¡to ¡have ¡a ¡reply ¡channel ¡ – Holds ¡a ¡socket ¡connec,on ¡ setup ¡ open ¡– ¡Con,nua,ons ¡can ¡be ¡ used ¡ – Considered ¡a ¡security ¡risk ¡by ¡ some ¡ – Harder ¡to ¡implement ¡durable ¡ connec,ons ¡ – Reliability ¡complicated ¡– ¡did ¡ the ¡data ¡arrive ¡

  12. REST ¡or ¡Real-­‑,me? ¡ • Real-­‑,me ¡APIs ¡are ¡addi,ve ¡to ¡an ¡exis,ng ¡REST ¡ or ¡SOAP ¡API ¡ • Invoca,on ¡seman,cs ¡are ¡different ¡ – Client ¡needs ¡to ¡handle ¡two ¡invoca,on ¡models ¡ • Real-­‑,me ¡APIs ¡are ¡mostly ¡used ¡to ¡query ¡data ¡ – Usually ¡not ¡to ¡perform ¡CRUD ¡opera,ons ¡ • Have ¡different ¡SLA ¡and ¡reliability ¡requirements ¡

  13. REST ¡or ¡Real-­‑,me? ¡ consumer ¡ REST ¡API ¡ Streaming ¡API ¡ Resource ¡A ¡ Resource ¡B ¡ Resource ¡C ¡ Transport ¡ Subscrip,on ¡ Manager ¡ Query ¡ Processor ¡

  14. Real-­‑,me ¡Technologies ¡ • Transport ¡ – Comet ¡(HTTP) ¡ – WebSocket ¡(HTTP) ¡ • Protocols ¡ – With ¡formal ¡pub/sub ¡seman,cs: ¡ • XMPP ¡ • Bayeux ¡ • STOMP ¡ – Ad ¡hoc, ¡ie ¡"subscrip,on" ¡expressed ¡in ¡the ¡request: ¡ • JSON ¡ • Push ¡ – PubSubHubbub ¡ – Web ¡Hooks ¡

  15. Real-­‑,me ¡APIs ¡are ¡real ¡ API ¡ Real-­‑;me ¡technology/protocol ¡ Salesforce ¡ Comet ¡ Facebook ¡ PubSubHubbub ¡ Instagram ¡ Ah ¡Hoc ¡(WebHooks/PubSubHubbub) ¡ Twiier ¡ Ad ¡Hoc ¡(Comet) ¡ PubNub ¡ Ad ¡Hoc ¡ SuperFeedr ¡ XMPP ¡ Pusher ¡ Ad ¡Hoc ¡(WebSockets) ¡

  16. Real-­‑,me ¡APIs: ¡REST ¡+ ¡JSON ¡or ¡XML ¡ 1% ¡of ¡all ¡APIs ¡support ¡real-­‑,me ¡interac,on ¡ source: ¡ProgrammableWeb.com ¡

  17. Stop. ¡Demo ¡,me! ¡

  18. Demo ¡1: ¡AJAX ¡ Streaming ¡API ¡ HTTP ¡Long ¡ Transport ¡ Polling ¡ Subscrip,on ¡ CometD ¡ Manager ¡ Query ¡ <None> ¡ Processor ¡ hips://github.com/rossmason/mule-­‑streaming-­‑api-­‑demo ¡ ¡

  19. Demo ¡2: ¡WebSockets ¡ Streaming ¡API ¡ Transport ¡ WebSocket ¡ Subscrip,on ¡ JMS ¡ Manager ¡ Query ¡ Esper ¡ Processor ¡ hips://github.com/rossmason/mule-­‑streaming-­‑api-­‑demo ¡ ¡

  20. Mule ¡real-­‑,me ¡API ¡support ¡ Technologies ¡ 3 rd ¡Party ¡APIs ¡ • CometD ¡ • Salesforce ¡Streaming ¡API ¡ • Web ¡Sockets ¡ • Facebook ¡real-­‑,me ¡API ¡ • Ad ¡Hoc ¡ • Twiier ¡Firehose ¡ • PubSubHubbub ¡ • PubNub ¡ • XMPP ¡ • STOMP ¡ • WebHooks ¡

  21. Real-­‑,me ¡Web ¡SotN ¡ • S,ll ¡in ¡early ¡adopter ¡territory ¡ – But ¡some ¡major ¡APIs ¡use ¡this ¡approach ¡ • Limita,ons ¡ – No ¡discovery ¡protocol ¡(i.e. ¡WADL) ¡ – Many ¡different ¡methods ¡ • Some ¡hampered ¡by ¡older ¡browser ¡technology ¡(i.e. ¡Web ¡ Sockets ¡

  22. Thank ¡You! ¡ • Twiier: ¡@rossmason, ¡@muleso= ¡ • Slides: ¡hip://slideshare.net/rossmason ¡ • Code: ¡ hips://github.com/rossmason/mule-­‑streaming-­‑api-­‑demo ¡ ¡ • Blog: ¡hip://blogs.muleso=.org ¡ • We ¡are ¡hiring: ¡hip://muleso=.com.careers ¡ ¡

Download Presentation
Download Policy: The content available on the website is offered to you 'AS IS' for your personal information and use only. It cannot be commercialized, licensed, or distributed on other websites without prior consent from the author. To download a presentation, simply click this link. If you encounter any difficulties during the download process, it's possible that the publisher has removed the file from their server.

Recommend


More recommend