the cloud-natives are restless

41
The Cloud-Natives are RESTless

Upload: konrad-malawski

Post on 16-Apr-2017

427 views

Category:

Technology


0 download

TRANSCRIPT

Page 1: The Cloud-natives are RESTless

The Cloud-Natives are RESTless

Page 2: The Cloud-natives are RESTless

Konrad `@ktosopl` Malawski

Akka Core,Akka Persistence,

Akka HTTP,Reactive Streams

Page 3: The Cloud-natives are RESTless

The concurrent & distributed applications toolkit

Akka is a toolkit and runtime for building highly concurrent, distributed, and resilient message-driven applications on the JVM

Page 4: The Cloud-natives are RESTless

The concurrent & distributed applications toolkit

Akka is a toolkit and runtime for building highly concurrent, distributed, and resilient message-driven applications on the JVM

Page 5: The Cloud-natives are RESTless

Actors – Concurrency / high perf. messaging Cluster – Location transparent, resilient clusters Persistence – EventSourcing support (many DBs) HTTP – Fully Async & Reactive Http Server and much more (kafka, cassandra, testing, …)

Page 6: The Cloud-natives are RESTless

http://cidrdb.org/cidr2005/papers/P12.pdf

“Data on the Outside, versus Data on the Inside”

Pat Helland

Page 7: The Cloud-natives are RESTless

“Communication on the Outside, versus Communication on the Inside”

Page 8: The Cloud-natives are RESTless

”The actor model in computer science is a mathematical model of concurrent computation that treats actors as the universal primitives of concurrent computation. ”

Wikipedia

The Actor Model

Page 9: The Cloud-natives are RESTless

An Actor

and acts on them by: • Sending messages • Changing its state / behaviour

• Creating more actors

receives messages

Page 10: The Cloud-natives are RESTless

An ActorA concurrency and distribution construct.

an addressable, location-transparent, entity

Show diagram showing people interacting with each other.

Page 11: The Cloud-natives are RESTless

Not Only Server-Client

Page 12: The Cloud-natives are RESTless

HTTP/2 “push” still needs a “pull”

https://blog.cloudflare.com/announcing-support-for-http-2-server-push-2

Page 13: The Cloud-natives are RESTless

Clusters, direct, p2p communication

Page 14: The Cloud-natives are RESTless

Clusters, direct, p2p communication

Page 15: The Cloud-natives are RESTless

Clusters, direct, p2p communication

Page 16: The Cloud-natives are RESTless

Clusters, direct, p2p communication

Page 17: The Cloud-natives are RESTless

Not Only JSON

“The Internet is running in debug mode.” — Rüdiger Möller

http://java-is-the-new-c.blogspot.de/2014/10/why-protocols-are-messy-concept.html

Page 18: The Cloud-natives are RESTless

Not Only JSON: Example dataMediaContent {

media = Media {

uri = "http://javaone.com/keynote.mpg"

title = "Javaone Keynote"

width = 640

height = 480

format = "video/mpg4"

duration = 18000000

size = 58982400

bitrate = 262144

persons = ["Bill Gates", "Steve Jobs"]

player = JAVA

copyright = null

}

}

images = [

Image {

uri = "http://javaone.com/keynote_large.jpg"

title = "Javaone Keynote"

width = 1024

height = 768

size = LARGE

}

Image {

uri = "http://javaone.com/keynote_small.jpg"

title = "Javaone Keynote"

width = 320

height = 240

size = SMALL

}

]

Page 19: The Cloud-natives are RESTless

Not Only JSON create ser deser total size protostuff 68 433 634 1067ns 239bytes protobuf 121 1173 719 1891 239 kryo-serializer 53 1480 1331 2810 286 thrift 95 1455 731 2186 349

. . . json/jackson/manual 52 1039 1228 2267 468 json/jackson/databind 54 1164 1866 3030 485 json/gson/databind 56 4667 4403 9070 486 xml/xstream+c-aalto 54 3310 6732 10042 525 xml/JAXB 54 4354 141333 145686 719 java-built-in 53 5046 23279 28325 889

Slide only to illustrate order-of-magniture differences. Don’t over-focus on numbers.

All details here: https://github.com/eishay/jvm-serializers/wiki

Page 20: The Cloud-natives are RESTless

Not Only JSON create ser deser total size protostuff 68 433 634 1067ns 239bytes protobuf 121 1173 719 1891 239 kryo-serializer 53 1480 1331 2810 286 thrift 95 1455 731 2186 349

. . . json/jackson/manual 52 1039 1228 2267 468 json/jackson/databind 54 1164 1866 3030 485 json/gson/databind 56 4667 4403 9070 486 xml/xstream+c-aalto 54 3310 6732 10042 525 xml/JAXB 54 4354 141333 145686 719 java-built-in 53 5046 23279 28325 889

Slide only to illustrate order-of-magniture differences. Don’t over-focus on numbers.

All details here: https://github.com/eishay/jvm-serializers/wiki

Page 21: The Cloud-natives are RESTless

Not Only JSON create ser deser total size protostuff 68 433 634 1067ns 239bytes protobuf 121 1173 719 1891 239 kryo-serializer 53 1480 1331 2810 286 thrift 95 1455 731 2186 349

. . . json/jackson/manual 52 1039 1228 2267 468 json/jackson/databind 54 1164 1866 3030 485 json/gson/databind 56 4667 4403 9070 486 xml/xstream+c-aalto 54 3310 6732 10042 525 xml/JAXB 54 4354 141333 145686 719 java-built-in 53 5046 23279 28325 889

Slide only to illustrate order-of-magniture differences. Don’t over-focus on numbers.

All details here: https://github.com/eishay/jvm-serializers/wiki

Page 22: The Cloud-natives are RESTless

Actually solving a real problem for fun and profit.

Reactive Streams

Page 23: The Cloud-natives are RESTless

Reactive Streams – why it all started

Page 24: The Cloud-natives are RESTless

Reactive Streams – why it all started

Page 25: The Cloud-natives are RESTless

Reactive Streams – why it all started

~2013:

Reactive Programming becoming widely adopted on JVM.

- Play introduced “Iteratees”- Akka (2009) had Akka-IO (TCP etc.)- Ben starts work on RxJava

http://blogs.msdn.com/b/rxteam/archive/2009/11/17/announcing-reactive-extensions-rx-for-net-silverlight.aspxhttp://infoscience.epfl.ch/record/176887/files/DeprecatingObservers2012.pdf - Ingo Maier, Martin Odersky

https://github.com/ReactiveX/RxJava/graphs/contributorshttps://github.com/reactor/reactor/graphs/contributors

https://medium.com/@viktorklang/reactive-streams-1-0-0-interview-faaca2c00bec#.69st3rndy

Teams discuss need for back-pressure in simple user API.Play’s Iteratee / Akka’s NACK in IO.

} } A lot more people join discussions, Reactive Streams are born.

Page 26: The Cloud-natives are RESTless

Advantages of Async Messaging

Page 27: The Cloud-natives are RESTless

Time holding Connection

Page 28: The Cloud-natives are RESTless

Time holding Connection

Page 29: The Cloud-natives are RESTless

Time holding Connection

Page 30: The Cloud-natives are RESTless

Time holding Connection

AFAIK: Addressed by HTTP/2,

since you can open “subStreams.”

Page 31: The Cloud-natives are RESTless

Long running task, sync vs. async

Page 32: The Cloud-natives are RESTless

Long running task, sync vs. async

Page 33: The Cloud-natives are RESTless

Long running task, sync vs. async

Page 34: The Cloud-natives are RESTless

Back-pressure in Action

Page 35: The Cloud-natives are RESTless

Streaming from Akka HTTP

Page 36: The Cloud-natives are RESTless

Streaming from Akka HTTP

No demand from TCP=

No demand upstream=

Source won’t generate tweets

Page 37: The Cloud-natives are RESTless

Streaming from Akka HTTP

No demand from TCP=

No demand upstream=

Source won’t generate tweets

=>

Page 38: The Cloud-natives are RESTless

Streaming from Akka HTTP

No demand from TCP=

No demand upstream=

Source won’t generate tweets

=>Bounded memory stream processing!

Page 39: The Cloud-natives are RESTless

Only the tip of the iceberg

Page 40: The Cloud-natives are RESTless

Akka Clusterand cluster tools

Akka Streamsasync & back-pressured

More tools in the toolbox

Page 41: The Cloud-natives are RESTless

Further reading:Reactive Streams: reactive-streams.org Akka documentation: akka.io/docs Free O’Reilly report – very out soon.

Get involved: sources: github.com/akka/akka mailing list: akka-user @ google groups gitter channel: https://gitter.im/akka/akka

Contact: Konrad [email protected] Malawski http://kto.so / @ktosopl