The Cloud-Natives are RESTless
Konrad `@ktosopl` Malawski
Akka Core,Akka Persistence,
Akka HTTP,Reactive Streams
The concurrent & distributed applications toolkit
Akka is a toolkit and runtime for building highly concurrent, distributed, and resilient message-driven applications on the JVM
The concurrent & distributed applications toolkit
Akka is a toolkit and runtime for building highly concurrent, distributed, and resilient message-driven applications on the JVM
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, …)
http://cidrdb.org/cidr2005/papers/P12.pdf
“Data on the Outside, versus Data on the Inside”
Pat Helland
“Communication on the Outside, versus Communication on the Inside”
”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
An Actor
and acts on them by: • Sending messages • Changing its state / behaviour
• Creating more actors
receives messages
An ActorA concurrency and distribution construct.
an addressable, location-transparent, entity
Show diagram showing people interacting with each other.
Not Only Server-Client
HTTP/2 “push” still needs a “pull”
https://blog.cloudflare.com/announcing-support-for-http-2-server-push-2
Clusters, direct, p2p communication
Clusters, direct, p2p communication
Clusters, direct, p2p communication
Clusters, direct, p2p communication
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
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
}
]
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
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
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
Actually solving a real problem for fun and profit.
Reactive Streams
Reactive Streams – why it all started
Reactive Streams – why it all started
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.
Advantages of Async Messaging
Time holding Connection
Time holding Connection
Time holding Connection
Time holding Connection
AFAIK: Addressed by HTTP/2,
since you can open “subStreams.”
Long running task, sync vs. async
Long running task, sync vs. async
Long running task, sync vs. async
Back-pressure in Action
Streaming from Akka HTTP
Streaming from Akka HTTP
No demand from TCP=
No demand upstream=
Source won’t generate tweets
Streaming from Akka HTTP
No demand from TCP=
No demand upstream=
Source won’t generate tweets
=>
Streaming from Akka HTTP
No demand from TCP=
No demand upstream=
Source won’t generate tweets
=>Bounded memory stream processing!
Only the tip of the iceberg
Akka Clusterand cluster tools
Akka Streamsasync & back-pressured
More tools in the toolbox
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