QCon NY 2014 - Evolving REST for an IoT World

42
Evolving REST for an IoT World Todd L. Montgomery @toddlmontgomery

description

 

Transcript of QCon NY 2014 - Evolving REST for an IoT World

Page 1: QCon NY 2014 - Evolving REST for an IoT World

Evolving REST for an IoT World

Todd L. Montgomery@toddlmontgomery

Page 2: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

Representational State Transfer

http://en.wikipedia.org/wiki/Representational_state_transfer

Page 3: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

pro·to·col  noun \ˈprō-tə-ˌkol, -ˌ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>

Page 4: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

Client - Server

Cacheable

Stateless

Page 5: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

Uniform InterfaceHypermedia, Resources,

URIs

Layered

Hmmm…

Page 6: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

REST Ecosystem

Page 7: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

Tools - CLI

Browser

JSON

Fast, EasyIntegration

HTTP/1.1,TCP,[TLS/SSL], IP

Page 8: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

IoT/IoE Ecosystem

Page 9: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

Boards & Kits

Environments

JSON??

EvolvingRapidly

HTTP/1.1

TLS/SSL?

TCP

IP

Bluetooth

MQTT

SCADA

Application

App? App

MultipleStacks

Page 10: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

Communication Patterns

Request/Response

Streaming “Ingest”

Publish/Subscribe

Request/Response

Page 11: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

History & Evolution

Page 12: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

Request

Response

HTTPRFC 2068, 2616, …, 7230-7240

SynchronousRequest/Response

Bi-Directional… kinda,but…

Event

Event

… onlyone direction

at-a-time

June 2014

Page 13: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

Request

Response

Delay

Delay

Processing

What happenshere whilewaiting?

…Nothing…

Stop-and-Wait

HTTP

Page 14: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

image courtesy www.tensator.com

Head-Of-LineBlocking

Page 15: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

Latency Sensitivity

Page 16: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

Mobile“OK” Bandwidth + Long RTT + High Loss Rate + No Effective HTTP Pipelining

http://en.wikipedia.org/wiki/HTTP_pipelining

Truly Awful User Experiences

Page 17: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

Asynchronous Request / Response

Unlock More Reactive Patterns!

Page 18: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

Request

ACKResponse

ACK

SyncRequest

SyncResponse

Web Services

But… Async Request/Response… kinda

Event

Event

http://en.wikipedia.org/wiki/List_of_web_service_specifications

No, seriously, lots of these!!

Page 19: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

Thankfully, Locked within theEnterprise…

Mostly…

Page 20: QCon NY 2014 - Evolving REST for an IoT World

@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…

Page 21: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

HTCPCPRFC 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"

Page 22: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

Page 23: QCon NY 2014 - Evolving REST for an IoT World

@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, authorhttp://larry.masinter.net/

Page 24: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

Why is HTTP used?

Easy firewall traversal

Simple, Flexible, FamiliarWorks with Anything

AddressingTooling

Page 25: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

Communication Patterns

Request/Response

Streaming “Ingest”

Publish/Subscribe

Request/Response

Page 26: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

Request

Response

Support(UI/Device)

Security(Challenge)

Keep-Aliveor Watchdog

User StateQuery

Page 27: QCon NY 2014 - Evolving REST for an IoT World

@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!

Page 28: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

NewProtocols & Standards

Page 29: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

AsyncRequest/Response

Streaming

WebSocketRFC 6455

Full Duplex, Asynchronous“TCP over the Web”

EventsEvents

101 Switch

HTTP Upgrade

Ingest

https://tools.ietf.org/html/rfc6455

Really aTransportProtocol

Page 30: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

AsyncRequest

AsyncResponse

SPDY & HTTP/2IETF Drafts

Async Request/ResponseMultiple Streams

Efficient Headers (HPACK)Binary Encoding

EventsEvents

http://www.ietf.org/id/draft-ietf-httpbis-http2-12.txt

Page 31: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

AsyncRequest

AsyncResponse

WebSocket over HTTP/2IETF Draft

Streaming Ingest

Full Duplex, Asynchronouswith Multiple Channels/Streams

Events Events

http://www.ietf.org/id/draft-hirano-httpbis-websocket-over-http2-00.txt

Page 32: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

MQ Telemetry Transport (MQTT)

http://mqtt.org/

LightweightPublish/Subscribe

Messaging Transport

Runs over TCPor WebSocket (v3.1.1)

MQTT-SN for non-TCP/IP

Broker-Based

OASIS Standard

Page 33: QCon NY 2014 - Evolving REST for an IoT World

@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 HTTPMapping

Resource Discovery,Linking, etc.

IETF CoRE WG (Constrained RESTful Environments)

Page 34: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

Sustain REST Principles

Standards-BasedEasily Parsed

Efficient Handling of Data/Metadata

Flexible - Easily ExtendedEasy to Implement

Requirements

Page 35: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

Possible Game Plan(s)

WebSocket + MQTTHTTP/2

WebSocket + CoAP WebSocket + HPACK

Combining IoT & REST

Page 36: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

HTTP/2

Nothing Optional,TLS, HPACK, etc.

Familiar Primitives

More complexthan HTTP/1.1

Ecosystems:REST Yes,

IoT No

Page 37: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

WebSocket + MQTT

HTTP Mapping?WebSocket can adapt

Some GuaranteedMessaging Semantics

Ecosystems:IoT Yes,

REST No (w/o WS)

Enables ManyPatterns

Page 38: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

WebSocket + HPACK

http://www.ietf.org/id/draft-ietf-httpbis-header-compression-07.txt

HPACK handlesmethod + headers

Use header forStream ID

Not a Standard, but

made of Standards

HPACK is (subjectively)

complex

Page 39: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

WebSocket + CoAP

http://www.ietf.org/id/draft-savolainen-core-coap-websockets-02.txt

HTTP Mapping

Ecosystems:REST Yes,

IoT Yes

NoGuaranteedMessaging

Not Broker-based,Peer-to-Peer

Page 40: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

One More Thing…

JSON

Page 41: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

Binary Encoding

Thing 1 Thing 2Not 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)

Page 42: QCon NY 2014 - Evolving REST for an IoT World

@toddlmontgomery

Questions?• Kaazing http://www.kaazing.com• Slideshare http://www.slideshare.com/toddleemontgomery• Twitter @toddlmontgomery

Thank You!