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 Actor
A 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 data
MediaContent {
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.aspx
http://infoscience.epfl.ch/record/176887/files/DeprecatingObservers2012.pdf - Ingo Maier, Martin Odersky
https://github.com/ReactiveX/RxJava/graphs/contributors
https://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 Cluster
and cluster tools
Akka Streams
async & 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 ktoso@lightbend.com Malawski
http://kto.so / @ktosopl

The Cloud-natives are RESTless @ JavaOne

  • 1.
  • 2.
    Konrad `@ktosopl` Malawski AkkaCore, Akka Persistence, Akka HTTP, Reactive Streams
  • 3.
    The concurrent &distributed applications toolkit Akka is a toolkit and runtime for building highly concurrent, distributed, and resilient message-driven applications on the JVM
  • 4.
    The concurrent &distributed applications toolkit Akka is a toolkit and runtime for building highly concurrent, distributed, and resilient message-driven applications on the JVM
  • 5.
    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, …)
  • 6.
    http://cidrdb.org/cidr2005/papers/P12.pdf “Data on theOutside, versus Data on the Inside” Pat Helland
  • 7.
    “Communication on theOutside, versus Communication on the Inside”
  • 8.
    ”The actor modelin computer science is a mathematical model of concurrent computation that treats actors as the universal primitives of concurrent computation. ” Wikipedia The Actor Model
  • 9.
    An Actor and actson them by: • Sending messages • Changing its state / behaviour • Creating more actors receives messages
  • 10.
    An Actor A concurrencyand distribution construct. an addressable, location-transparent, entity Show diagram showing people interacting with each other.
  • 11.
  • 12.
    HTTP/2 “push” stillneeds a “pull” https://blog.cloudflare.com/announcing-support-for-http-2-server-push-2
  • 13.
    Clusters, direct, p2pcommunication
  • 14.
    Clusters, direct, p2pcommunication
  • 15.
    Clusters, direct, p2pcommunication
  • 16.
    Clusters, direct, p2pcommunication
  • 17.
    Not Only JSON “TheInternet 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
  • 18.
    Not Only JSON:Example data MediaContent { 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 } ]
  • 19.
    Not Only JSONcreate 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
  • 20.
    Not Only JSONcreate 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
  • 21.
    Not Only JSONcreate 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
  • 22.
    Actually solving areal problem for fun and profit. Reactive Streams
  • 23.
    Reactive Streams –why it all started
  • 24.
    Reactive Streams –why it all started
  • 25.
    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.aspx http://infoscience.epfl.ch/record/176887/files/DeprecatingObservers2012.pdf - Ingo Maier, Martin Odersky https://github.com/ReactiveX/RxJava/graphs/contributors https://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.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
    Time holding Connection AFAIK: Addressedby HTTP/2, since you can open “subStreams.”
  • 31.
    Long running task,sync vs. async
  • 32.
    Long running task,sync vs. async
  • 33.
    Long running task,sync vs. async
  • 34.
  • 35.
  • 36.
    Streaming from AkkaHTTP No demand from TCP = No demand upstream = Source won’t generate tweets
  • 37.
    Streaming from AkkaHTTP No demand from TCP = No demand upstream = Source won’t generate tweets =>
  • 38.
    Streaming from AkkaHTTP No demand from TCP = No demand upstream = Source won’t generate tweets => Bounded memory stream processing!
  • 39.
    Only the tipof the iceberg
  • 40.
    Akka Cluster and clustertools Akka Streams async & back-pressured More tools in the toolbox
  • 41.
    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 ktoso@lightbend.com Malawski http://kto.so / @ktosopl