QCon NY 2014 - Evolving REST for an IoT World

3,339 views
3,093 views

Published on

Published in: Software, Technology

QCon NY 2014 - Evolving REST for an IoT World

  1. 1. Evolving REST for an IoT World Todd L. Montgomery @toddlmontgomery
  2. 2. @toddlmontgomery Representational State Transfer http://en.wikipedia.org/wiki/Representational_state_transfer
  3. 3. @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>
  4. 4. @toddlmontgomery Client - Server Cacheable Stateless
  5. 5. @toddlmontgomery Uniform Interface Hypermedia, Resources, URIs Layered Hmmm…
  6. 6. @toddlmontgomery REST Ecosystem
  7. 7. @toddlmontgomery Tools - CLI Browser JSON Fast, Easy Integration HTTP/1.1,TCP, [TLS/SSL], IP
  8. 8. @toddlmontgomery IoT/IoE Ecosystem
  9. 9. @toddlmontgomery Boards & Kits Environments JSON ?? Evolving Rapidly HTTP/1.1 TLS/SSL? TCP IP Bluetooth MQTT SCADA Application App? App Multiple Stacks
  10. 10. @toddlmontgomery Communication Patterns Request/Response Streaming “Ingest” Publish/Subscribe Request/Response
  11. 11. @toddlmontgomery History & Evolution
  12. 12. @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
  13. 13. @toddlmontgomery Request Response Delay Delay Processing What happens here while waiting? …Nothing… Stop-and-Wait HTTP
  14. 14. @toddlmontgomery image courtesy www.tensator.com Head-Of-Line Blocking
  15. 15. @toddlmontgomery Latency Sensitivity
  16. 16. @toddlmontgomery Mobile “OK” Bandwidth + Long RTT + High Loss Rate + No Effective HTTP Pipelining http://en.wikipedia.org/wiki/HTTP_pipelining Truly Awful User Experiences
  17. 17. @toddlmontgomery Asynchronous Request / Response Unlock More Reactive Patterns!
  18. 18. @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!!
  19. 19. @toddlmontgomery Thankfully, Locked within the Enterprise… Mostly…
  20. 20. @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…
  21. 21. @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"
  22. 22. @toddlmontgomery
  23. 23. @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/
  24. 24. @toddlmontgomery Why is HTTP used? Easy firewall traversal Simple, Flexible, Familiar Works with Anything Addressing Tooling
  25. 25. @toddlmontgomery Communication Patterns Request/Response Streaming “Ingest” Publish/Subscribe Request/Response
  26. 26. @toddlmontgomery Request Response Support (UI/Device) Security (Challenge) Keep-Alive or Watchdog User State Query
  27. 27. @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!
  28. 28. @toddlmontgomery New Protocols & Standards
  29. 29. @toddlmontgomery Async Request/ Response Streaming WebSocket RFC 6455 Full Duplex, Asynchronous “TCP over the Web” EventsEvents Ingest https://tools.ietf.org/html/rfc6455 Really a Transport Protocol
  30. 30. @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
  31. 31. @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
  32. 32. @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
  33. 33. @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)
  34. 34. @toddlmontgomery Sustain REST Principles Standards-BasedEasily Parsed Efficient Handling of Data/Metadata Flexible - Easily ExtendedEasy to Implement Requirements
  35. 35. @toddlmontgomery Possible Game Plan(s) WebSocket + MQTTHTTP/2 WebSocket + CoAP WebSocket + HPACK Combining IoT & REST
  36. 36. @toddlmontgomery HTTP/2 Nothing Optional, TLS, HPACK, etc. Familiar Primitives More complex than HTTP/1.1 Ecosystems: REST Yes, IoT No
  37. 37. @toddlmontgomery WebSocket + MQTT HTTP Mapping? WebSocket can adapt Some Guaranteed Messaging Semantics Ecosystems: IoT Yes, REST No (w/o WS) Enables Many Patterns
  38. 38. @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
  39. 39. @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
  40. 40. @toddlmontgomery One More Thing… JSON
  41. 41. @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)
  42. 42. @toddlmontgomery Questions? • Kaazing http://www.kaazing.com • Slideshare http://www.slideshare.com/toddleemontgomery • Twitter @toddlmontgomery Thank You!

×