Evolving REST for an IoT World


Published on

Video and slides synchronized, mp3 and slide download available at URL http://bit.ly/1kYLiRR.

Todd Montgomery explains using WebSocket and reactive programming in an event driven RESTful architecture for the emerging IoT world. Filmed at qconnewyork.com.

Todd Montgomery is a networking hacker who has researched, designed, and built numerous protocols, messaging-oriented middleware systems, and real-time data systems, done research for NASA, contributed to the IETF and IEEE, and co-founded two startups. He currently works for Kaazing as Chief Architect.

Published in: Technology
  • Be the first to comment

No Downloads
Total views
On SlideShare
From Embeds
Number of Embeds
Embeds 0
No embeds

No notes for slide

Evolving REST for an IoT World

  1. 1. Evolving REST for an IoT World Todd L. Montgomery @toddlmontgomery
  2. 2. InfoQ.com: News & Community Site • 750,000 unique visitors/month • Published in 4 languages (English, Chinese, Japanese and Brazilian Portuguese) • Post content from our QCon conferences • News 15-20 / week • Articles 3-4 / week • Presentations (videos) 12-15 / week • Interviews 2-3 / week • Books 1 / month Watch the video with slide synchronization on InfoQ.com! http://www.infoq.com/presentations /rest-websocket-iot
  3. 3. Presented at QCon New York www.qconnewyork.com Purpose of QCon - to empower software development by facilitating the spread of knowledge and innovation Strategy - practitioner-driven conference designed for YOU: influencers of change and innovation in your teams - speakers and topics driving the evolution and innovation - connecting and catalyzing the influencers and innovators Highlights - attended by more than 12,000 delegates since 2007 - held in 9 cities worldwide
  4. 4. @toddlmontgomery Representational State Transfer http://en.wikipedia.org/wiki/Representational_state_transfer
  5. 5. @toddlmontgomery pro·to·col noun ˈprō-tə-ˌkȯl, -ˌkōl, -ˌkäl, -kəl ! ... ! 3 b : a set of conventions governing the treatment and especially the formatting of data in an electronic communications system <network protocols> ... 3 a : a code prescribing strict adherence to correct etiquette and precedence (as in diplomatic exchange and in the military services) <a breach of protocol> !
  6. 6. @toddlmontgomery Client - Server Cacheable Stateless
  7. 7. @toddlmontgomery Uniform Interface Hypermedia, Resources, URIs Layered Hmmm…
  8. 8. @toddlmontgomery REST Ecosystem
  9. 9. @toddlmontgomery Tools - CLI Browser JSON Fast, Easy Integration HTTP/1.1,TCP, [TLS/SSL], IP
  10. 10. @toddlmontgomery IoT/IoE Ecosystem
  11. 11. @toddlmontgomery Boards & Kits Environments JSON ?? Evolving Rapidly HTTP/1.1 TLS/SSL? TCP IP Bluetooth MQTT SCADA Application App? App Multiple Stacks
  12. 12. @toddlmontgomery Communication Patterns Request/Response Streaming “Ingest” Publish/Subscribe Request/Response
  13. 13. @toddlmontgomery History & Evolution
  14. 14. @toddlmontgomery Request Response HTTP RFC 2068, 2616, …, 7230-7240 Synchronous Request/Response Bi-Directional… kinda, but… Event Event … only one direction at-a-time June 2014
  15. 15. @toddlmontgomery Request Response Delay Delay Processing What happens here while waiting? …Nothing… Stop-and-Wait HTTP
  16. 16. @toddlmontgomery image courtesy www.tensator.com Head-Of-Line Blocking
  17. 17. @toddlmontgomery Latency Sensitivity
  18. 18. @toddlmontgomery Mobile “OK” Bandwidth + Long RTT + High Loss Rate + No Effective HTTP Pipelining http://en.wikipedia.org/wiki/HTTP_pipelining Truly Awful User Experiences
  19. 19. @toddlmontgomery Asynchronous Request / Response Unlock More Reactive Patterns!
  20. 20. @toddlmontgomery Request ACK Response ACK Sync Request Sync Response Web Services … But… Async Request/Response… kinda Event Event http://en.wikipedia.org/wiki/List_of_web_service_specifications No, seriously, lots of these!!
  21. 21. @toddlmontgomery Thankfully, Locked within the Enterprise… Mostly…
  22. 22. @toddlmontgomery “Yeah, yeah, but your scientists were so preoccupied with whether or not they could that they didn't stop to think if they should.” — Jurassic Park Philosophy of some REST APIs Just because you could use HTTP, doesn’t mean you should…
  23. 23. @toddlmontgomery HTCPCP RFC 2324, Extended by RFC 7168 http://en.wikipedia.org/wiki/Hyper_Text_Coffee_Pot_Control_Protocol "there is a strong, dark, rich requirement for a protocol designed espressoly [sic] for the brewing of coffee"
  24. 24. @toddlmontgomery
  25. 25. @toddlmontgomery 418 I’m a teapot BREW WHEN "This has a serious purpose – it identifies many of the ways in which HTTP has been extended inappropriately.” — Larry Masinter, author http://larry.masinter.net/
  26. 26. @toddlmontgomery Why is HTTP used? Easy firewall traversal Simple, Flexible, Familiar Works with Anything Addressing Tooling
  27. 27. @toddlmontgomery Communication Patterns Request/Response Streaming “Ingest” Publish/Subscribe Request/Response
  28. 28. @toddlmontgomery Request Response Support (UI/Device) Security (Challenge) Keep-Alive or Watchdog User State Query
  29. 29. @toddlmontgomery Battery Life Persistent connections help a LOT! Well designed protocols help a LOT MORE! Many simultaneous connections hurt! Using the wrong protocol with the wrong pattern hurts A LOT! The Wrong Patterns Hurt a LOT! Stay out of High Energy State!
  30. 30. @toddlmontgomery New Protocols & Standards
  31. 31. @toddlmontgomery Async Request/ Response Streaming WebSocket RFC 6455 Full Duplex, Asynchronous “TCP over the Web” EventsEvents 101 Switch HTTP Upgrade Ingest https://tools.ietf.org/html/rfc6455 Really a Transport Protocol
  32. 32. @toddlmontgomery Async Request Async Response SPDY & HTTP/2 IETF Drafts Async Request/Response Multiple Streams Efficient Headers (HPACK) Binary Encoding Events Events http://www.ietf.org/id/draft-ietf-httpbis-http2-12.txt
  33. 33. @toddlmontgomery Async Request Async Response WebSocket over HTTP/2 IETF Draft Streaming Ingest Full Duplex, Asynchronous with Multiple Channels/Streams Events Events http://www.ietf.org/id/draft-hirano-httpbis-websocket-over-http2-00.txt
  34. 34. @toddlmontgomery MQ Telemetry Transport (MQTT) http://mqtt.org/ Lightweight Publish/Subscribe Messaging Transport Runs over TCP or WebSocket (v3.1.1) MQTT-SN for non-TCP/IP Broker-Based OASIS Standard
  35. 35. @toddlmontgomery Constrained Application Protocol (CoAP) http://www.ietf.org/id/draft-ietf-core-coap-18.txt Runs over UDP, DTLS, or WebSocket Request/Response (either direction), Publish/Subscribe Standardized HTTP Mapping Resource Discovery, Linking, etc. IETF CoRE WG (Constrained RESTful Environments)
  36. 36. @toddlmontgomery Sustain REST Principles Standards-BasedEasily Parsed Efficient Handling of Data/Metadata Flexible - Easily ExtendedEasy to Implement Requirements
  37. 37. @toddlmontgomery Possible Game Plan(s) WebSocket + MQTTHTTP/2 WebSocket + CoAP WebSocket + HPACK Combining IoT & REST
  38. 38. @toddlmontgomery HTTP/2 Nothing Optional, TLS, HPACK, etc. Familiar Primitives More complex than HTTP/1.1 Ecosystems: REST Yes, IoT No
  39. 39. @toddlmontgomery WebSocket + MQTT HTTP Mapping? WebSocket can adapt Some Guaranteed Messaging Semantics Ecosystems: IoT Yes, REST No (w/o WS) Enables Many Patterns
  40. 40. @toddlmontgomery WebSocket + HPACK http://www.ietf.org/id/draft-ietf-httpbis-header-compression-07.txt HPACK handles method + headers Use header for Stream ID Not a Standard, but made of Standards HPACK is (subjectively) complex
  41. 41. @toddlmontgomery WebSocket + CoAP http://www.ietf.org/id/draft-savolainen-core-coap-websockets-02.txt HTTP Mapping Ecosystems: REST Yes, IoT Yes No Guaranteed Messaging Not Broker-based, Peer-to-Peer
  42. 42. @toddlmontgomery One More Thing… ! JSON
  43. 43. @toddlmontgomery Binary Encoding Thing 1 Thing 2 Not a human Also, …not a human Does not need to be human readable http://tools.ietf.org/html/rfc7049 Concise Binary Object Representation (COBR) FIX / Simple Binary Encoding (SBE) https://github.com/real-logic/simple-binary-encoding HPACK (Part of HTTP/2)
  44. 44. @toddlmontgomery Questions? • Kaazing http://www.kaazing.com • Slideshare http://www.slideshare.com/toddleemontgomery • Twitter @toddlmontgomery Thank You!
  45. 45. Watch the video with slide synchronization on InfoQ.com! http://www.infoq.com/presentations/rest- websocket-iot