reactive programming models for iot - goto...

51
Reactive Programming Models for IoT Todd L. Montgomery @toddlmontgomery

Upload: hadieu

Post on 30-May-2018

228 views

Category:

Documents


0 download

TRANSCRIPT

Reactive Programming Models for IoT

Todd L. Montgomery @toddlmontgomery

Internet of Things?

Just a Silicon Valley buzzword?

Psst! Already Here! Not New!

Reactive Programming?

Just another buzzword?

Psst! Also Not New!

Connecting “Things” …Reactively…

What most of us think happens

Request

Response

Request

Response

What really happens

And if not, we’ll make it!

Request

Response

What also really happens

But… Who does this?

@toddlmontgomery

Request

Response

Support (UI/Device)

Security (Challenge)

Keep-Alive or Watchdog

User State Query

Stream

What also really happens

News, Stocks, Texts/SMS, Video, Audio, Social, …

Ingest

What also really happens

Temperature, Heart Rate, Web Logs, Sensor Data, Seismic Readings, Steps, Stairs, Gyro

Data, GPS, Acceleration, Breathing, EKG, EEG, …

Request

Response

What also really happens

Stream & Ingest

Pretty much how everything actually works…

What also REALLY happens

Message

Message

The Break Down

Request, Response, Stream, and Ingest are really types

Message-Driven

Message-Driven

Reactive Applications

Message Driven

Responsive Resilient

Elastic

http://www.reactivemanifesto.org/

REST

RPC

Function Call

Message-Driven

LISP

Distributed Systems Evolution

IoT…

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

@toddlmontgomery

courtesy of

Sometimes it is good to reinvent the wheel

@toddlmontgomery

What History Has Taught Us

THE IoT Language!

THE IoT Protocol!

THE IoT Runtime!

THE IoT ______!

Internet of Things

Multi-Lingual (and Polyglot)

Multi-Protocol & Multi-Standard

Multi-“Platform” Huge Scale Highly Integrated

Connected. Integrated.

Great time to be a protocol geek!

Connected. Services. Tools.Nuklei

Multi-Lingual (and Polyglot)

Location Transparency

Multi-Protocol & Data Format

Basic Low-Level API

Protocols

Nuklei

Deployment Container

LogicReactive

Message Stream

Depends on language, runtime, platform, etc. Asynchronous

Binary “Loose” Ordering

Protocols

NukleiLogic

Reactive Message Stream

Asynchronous Binary Boundary

Basic read/write

API

Various Protocol Options

Choice of protocols becomes deployment concern

Deployment Container

Simple, consistent usage allows functional

composition of protocols

Protocols?

Shared Memory IPC

WebSocket

JMS

WebRTC

Not just in the traditional sense…

HTTP/1.1MQTT

HTTP/2

AMQPCoAP

TCP/UDP/IP

Aeron 0MQ

@toddlmontgomery

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

@toddlmontgomery

Protocols are the key to Integration

REST has demonstrated this!

@toddlmontgomery

Functional Protocol Composition

e.g. HTTP over TCP looks same as HTTP over IPC or HTTP over WebSocket or

HTTP over JMS

e.g. Streams over Messages is a form of Fragmentation/

Reassembly

Packet/Frame is common building block (Ethernet,

ATM, etc.)

Layering becomes natural & trivial. Also forces

boundaries & decoupling

Not New

@toddlmontgomery

Data Format

JSON

FIX / SBE CBOR

YAML

XML JMS Message

Divorced from Data Association

Map<> and other native associations are better than

format specific APIs

HPACK

@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 (CBOR)FIX / Simple Binary Encoding (SBE)

https://github.com/real-logic/simple-binary-encoding

HPACK (Part of HTTP/2)…

@toddlmontgomery

AddressingURIs - Just, but not only Strings

https://www.ietf.org Think about how much context this contains!

Define an Endpoint for Connectivity

Simple, Natural, & Familiar

@toddlmontgomery

Isolation & Location Transparency

Deployment Container docker, AWS, VM, …

Leverage Binding & Resolution to

decoupleMigration

Endpoint can be anywhere

Deployment Container

OS level isolation, don’t duplicate at the application layer

VM

AMI

App Server

@toddlmontgomery

Basic Low-Level API

“Common”Message/Packet/Frame -based

BSD Sockets has it right

From an old protocol hacker…

@toddlmontgomery

Defining a Service

★ Address = String ★ Service Logic = Lambda

Endpoint

Because they should be that simple

@toddlmontgomery

@FunctionalInterface public interface Mikro { void onMessage( Object header, int typeId, AtomicBuffer buffer, int offset, int length); }

Previous Protocol Flyweight

ByteBuffer on Steroids

@toddlmontgomery

Flyweights

Struct Overlays Semi-Stateful Parsers

Know how to access fields efficientlyPrefer to access via dead reckoning (stateless)

@toddlmontgomery

Sending to a Service

★ Proxy = Resolve(Address) ★ Proxy.send(Data)

From anything, not just another Service

For Efficiency, Reuse, and Caching

@toddlmontgomery

@FunctionalInterface public interface Proxy { int send( int typeId, AtomicBuffer buffer, int offset, int length); }

ByteBuffer on Steroids

@toddlmontgomery

Additionally…

Flow Control… Security…

Schedulers…Polyglot?…

Think Packet Scheduling?Java, then JavaScript, C, iOS,

Not an afterthought Also, not an afterthought

Message

Message

To Sum Up

https://github.com/kaazing/nuklei

Very Early & Still Evolving

Connected. Services. Tools.

@toddlmontgomery

Questions?

• Kaazing http://www.kaazing.com • GitHub https://github.com/kaazing • Slideshare http://www.slideshare.com/toddleemontgomery • Twitter @toddlmontgomery

Thank You!