Top Banner
Akka in 100 slides or less Derek Wyatt Twitter: @derekwyatt Email: [email protected] August 2015
93

Akka in 100 slides or less

Apr 16, 2017

Download

Software

Derek Wyatt
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Akka in 100 slides or less

Akkain 100 slides or less

Derek Wyatt Twitter: @derekwyatt

Email: [email protected] 2015

Page 2: Akka in 100 slides or less

Akka is Concurrency

Page 3: Akka in 100 slides or less

Akka is Concurrency

Actors: Living objects with concurrent context

“I am for you, Alrik of Valt.”

Page 4: Akka in 100 slides or less

Akka is Concurrency

Actors: Living objects with concurrent context

Futures: These aren’t Java’s Futures

val  futureData  =  for  {      response  <-­‐  httpGet(…)      query  =  response.body.as[Query]      (img,  text)  <-­‐  imageQuery(query)      scaledImg  <-­‐  scaleImg(img)  }  yield  NewPostData(text,  scaledImg)

“I am for you, Alrik of Valt.”

Page 5: Akka in 100 slides or less

Akka is Concurrency

Actors: Living objects with concurrent context

Futures: These aren’t Java’s Futures

val  futureData  =  for  {      response  <-­‐  httpGet(…)      query  =  response.body.as[Query]      (img,  text)  <-­‐  imageQuery(query)      scaledImg  <-­‐  scaleImg(img)  }  yield  NewPostData(text,  scaledImg)

Asynchronous

Asynchronous

Asynchronous

Asynchronous

“I am for you, Alrik of Valt.”

Page 6: Akka in 100 slides or less

Akka is Concurrency

Actors: Living objects with concurrent context

Futures: These aren’t Java’s Futures

val  futureData  =  for  {      response  <-­‐  httpGet(…)      query  =  response.body.as[Query]      (img,  text)  <-­‐  imageQuery(query)      scaledImg  <-­‐  scaleImg(img)  }  yield  NewPostData(text,  scaledImg)

Asynchronous

Asynchronous

Asynchronous

Asynchronous

Streams: Async Non-Blocking and Back-PressuredSource

Sink

Demand

Supply

Http too…

“I am for you, Alrik of Valt.”

Page 7: Akka in 100 slides or less

Akka is Concurrency

Actors: Living objects with concurrent context

Futures: These aren’t Java’s Futures

val  futureData  =  for  {      response  <-­‐  httpGet(…)      query  =  response.body.as[Query]      (img,  text)  <-­‐  imageQuery(query)      scaledImg  <-­‐  scaleImg(img)  }  yield  NewPostData(text,  scaledImg)

Asynchronous

Asynchronous

Asynchronous

Asynchronous

Streams: Async Non-Blocking and Back-PressuredSource

Sink

Demand

Supply

Http too…

“I am for you, Alrik of Valt.”

Support for Scala and Java (but use Scala, cuz…)

Page 8: Akka in 100 slides or less

Actors: Concurrency in Isolation

Page 9: Akka in 100 slides or less

Actors: Concurrency in Isolation

count: _alert: _score: _

Page 10: Akka in 100 slides or less

Actors: Concurrency in Isolationcount: 2alert: Yscore: 16

count: 4alert: Nscore: 2

count: 33alert: Gscore: 71

count: 13alert: Gscore: 12

count: 7alert: Xscore: 5

count: 8alert: Nscore: 11

count: 2alert: Iscore: 14

count: 87alert: Gscore: 0

count: 1alert: Bscore: 6

count: 7alert: Wscore: 32

count: 7alert: Oscore: 19

count: 4alert: Gscore: 99

count: _alert: _score: _

✗Construct as many as you’d like

Page 11: Akka in 100 slides or less

Actors: Concurrency in Isolationcount: 2alert: Yscore: 16

count: 4alert: Nscore: 2

count: 33alert: Gscore: 71

count: 13alert: Gscore: 12

count: 7alert: Xscore: 5

count: 8alert: Nscore: 11

count: 2alert: Iscore: 14

count: 87alert: Gscore: 0

count: 1alert: Bscore: 6

count: 7alert: Wscore: 32

count: 7alert: Oscore: 19

count: 4alert: Gscore: 99

count: _alert: _score: _

✗Construct as many as you’d like

✗Each one encapsulates its own state

Page 12: Akka in 100 slides or less

Actors: Concurrency in Isolationcount: 2alert: Yscore: 16

count: 4alert: Nscore: 2

count: 33alert: Gscore: 71

count: 13alert: Gscore: 12

count: 7alert: Xscore: 5

count: 8alert: Nscore: 11

count: 2alert: Iscore: 14

count: 87alert: Gscore: 0

count: 1alert: Bscore: 6

count: 7alert: Wscore: 32

count: 7alert: Oscore: 19

count: 4alert: Gscore: 99

Thre

ad

Thre

ad

count: _alert: _score: _

✗Construct as many as you’d like

✗Each one encapsulates its own state

✗They all (can) share the same thread pool

Page 13: Akka in 100 slides or less

Actors: Concurrency in Isolationcount: 2alert: Yscore: 16

count: 4alert: Nscore: 2

count: 33alert: Gscore: 71

count: 13alert: Gscore: 12

count: 7alert: Xscore: 5

count: 8alert: Nscore: 11

count: 2alert: Iscore: 14

count: 87alert: Gscore: 0

count: 1alert: Bscore: 6

count: 7alert: Wscore: 32

count: 7alert: Oscore: 19

count: 4alert: Gscore: 99

Thre

ad

Thre

ad

count: _alert: _score: _

✗Construct as many as you’d like

✗Each one encapsulates its own state

✗They all (can) share the same thread pool

✗They cannot interfere with each other

Page 14: Akka in 100 slides or less

Actors: Concurrency in Isolationcount: 2alert: Yscore: 16

count: 4alert: Nscore: 2

count: 33alert: Gscore: 71

count: 8alert: Nscore: 11

count: 2alert: Iscore: 14

count: 87alert: Gscore: 0

count: 1alert: Bscore: 6

count: 7alert: Wscore: 32

count: 7alert: Oscore: 19

count: 4alert: Gscore: 99

Thre

ad

Thre

ad

count: _alert: _score: _

✗Construct as many as you’d like

✗Each one encapsulates its own state

✗They all (can) share the same thread pool

✗They cannot interfere with each other

✗Their life-cycles are entirely under your control

Page 15: Akka in 100 slides or less

It’s all about the messages!

Page 16: Akka in 100 slides or less

It’s all about the messages!

Actors have no public methods⦿ A

Page 17: Akka in 100 slides or less

It’s all about the messages!

Actors have no public methods⦿

Actors have no publicly accessible data⦿

A B

Page 18: Akka in 100 slides or less

It’s all about the messages!

Actors have no public methods⦿

Actors have no publicly accessible data⦿

You cannot communicate with Actors Synchronously⦿

A B

Page 19: Akka in 100 slides or less

It’s all about the messages!

Actors have no public methods⦿

Actors have no publicly accessible data⦿

You cannot communicate with Actors Synchronously⦿

The only way to talk to them is with Messages⦿

A Bhey

Page 20: Akka in 100 slides or less

It’s all about the messages!

Actors have no public methods⦿

Actors have no publicly accessible data⦿

You cannot communicate with Actors Synchronously⦿

The only way to talk to them is with Messages⦿

The only way to access their data is with Messages⦿

A B83

Page 21: Akka in 100 slides or less

It’s all about the messages!

Actors have no public methods⦿

Actors have no publicly accessible data⦿

You cannot communicate with Actors Synchronously⦿

The only way to talk to them is with Messages⦿

The only way to access their data is with Messages⦿

Messages can (and should) carry conversational state⦿

A B

A

Page 22: Akka in 100 slides or less

It’s all about the messages!

Actors have no public methods⦿

Actors have no publicly accessible data⦿

You cannot communicate with Actors Synchronously⦿

The only way to talk to them is with Messages⦿

The only way to access their data is with Messages⦿

Messages can (and should) carry conversational state⦿

A B

A

Done(a,b,c)

Page 23: Akka in 100 slides or less

Actors are Fault Tolerant

Parent

Child Child Child

Mailbox

Mailbox

Mailbox Mailbox

Page 24: Akka in 100 slides or less

Actors are Fault Tolerant

Actors supervise their childrenParent

Child Child Child

Mailbox

Mailbox

Mailbox Mailbox

Page 25: Akka in 100 slides or less

Actors are Fault Tolerant

Actors supervise their children

Failed Actors are restarted (or stopped, or resumed, or escalated) by their supervisors

Parent

Child Child Child

Mailbox

Mailbox

Mailbox Mailbox

Page 26: Akka in 100 slides or less

Actors are Fault Tolerant

Actors supervise their children

Failed Actors are restarted (or stopped, or resumed, or escalated) by their supervisors

Restarted Actors are given a fresh state

Parent

Child Child Child

Mailbox

Mailbox

Mailbox Mailbox

Page 27: Akka in 100 slides or less

Actors are Fault Tolerant

Actors supervise their children

Failed Actors are restarted (or stopped, or resumed, or escalated) by their supervisors

Restarted Actors are given a fresh state

The message they were processing is lost

Parent

Child Child Child

Mailbox

Mailbox

Mailbox Mailbox

Page 28: Akka in 100 slides or less

Actors are Fault Tolerant

Actors supervise their children

Failed Actors are restarted (or stopped, or resumed, or escalated) by their supervisors

Restarted Actors are given a fresh state

The message they were processing is lost

Parent

Child Child

Mailbox

Mailbox

Mailbox Mailbox

Child

Page 29: Akka in 100 slides or less

Death is ActionableParent

Child ChildChild

Deathwatch

Mailbox

Page 30: Akka in 100 slides or less

Death is Actionable❉ Restarting is invisible to outsiders…

❉ …But Actor Death is visible

❉ Deathwatch lets Actors react to death, such as to recreate a child

Parent

Child ChildChild

Deathwatch

Mailbox

Page 31: Akka in 100 slides or less

Death is Actionable❉ Restarting is invisible to outsiders…

❉ …But Actor Death is visible

❉ Deathwatch lets Actors react to death, such as to recreate a child

Parent

ChildChildChild

Deathwatch

Mailbox

Page 32: Akka in 100 slides or less

Death is Actionable❉ Restarting is invisible to outsiders…

❉ …But Actor Death is visible

❉ Deathwatch lets Actors react to death, such as to recreate a child

Parent

ChildChildChild

Deathwatch

Mailbox

❉… Or a transaction is complete, or it’s time to shut down, or a current stage of processing is finished, or…

Page 33: Akka in 100 slides or less

Death is Actionable❉ Restarting is invisible to outsiders…

❉ …But Actor Death is visible

❉ Deathwatch lets Actors react to death, such as to recreate a child

Parent

ChildChildChild

Deathwatch

Mailbox

❉ Remember that this is death, so the mailbox contents are lost

❉… Or a transaction is complete, or it’s time to shut down, or a current stage of processing is finished, or…

Page 34: Akka in 100 slides or less

So, why would I use Actors?

Page 35: Akka in 100 slides or less

So, why would I use Actors?✗Actors help you manage concurrency Reasoning

Page 36: Akka in 100 slides or less

So, why would I use Actors?✗Actors help you manage concurrency

✗Actors let you implement services within your system

Reasoning

Service decoupling

Page 37: Akka in 100 slides or less

So, why would I use Actors?✗Actors help you manage concurrency

✗Actors let you implement services within your system

✗Actors let you design an entirely asynchronous system

Reasoning

Service decoupling

Capacity and Throughput

Page 38: Akka in 100 slides or less

So, why would I use Actors?✗Actors help you manage concurrency

✗Actors let you implement services within your system

✗Actors let you design an entirely asynchronous system

✗Actors let you define the resiliency of your applications

Reasoning

Service decoupling

Capacity and Throughput

Fault Tolerance

Page 39: Akka in 100 slides or less

So, why would I use Actors?✗Actors help you manage concurrency

✗Actors let you implement services within your system

✗Actors let you design an entirely asynchronous system

✗Actors let you define the resiliency of your applications

✗Eventual consistency, and message delivery failure are realities that Actors help you deal with throughout your code

Reasoning

Service decoupling

Capacity and Throughput

Fault Tolerance

Massive Scale

Self Healing

Page 40: Akka in 100 slides or less

So, why would I use Actors?✗Actors help you manage concurrency

✗Actors let you implement services within your system

✗Actors let you design an entirely asynchronous system

✗Actors let you define the resiliency of your applications

✗Eventual consistency, and message delivery failure are realities that Actors help you deal with throughout your code

✗Most importantly, Actors help you think about the problem differently and express your solutions more creatively

Reasoning

Service decoupling

Capacity and Throughput

Fault Tolerance

Massive Scale

Self Healing

Sanity, Clarity, and Reasonability!!

Page 41: Akka in 100 slides or less

“Functional” Futures

Page 42: Akka in 100 slides or less

“Functional” Futures◎ A Future is just a value, but not yet…

Page 43: Akka in 100 slides or less

“Functional” Futures◎ A Future is just a value, but not yet…

◎java.util.concurrent.Future is a bad Future. Akka gave us Futures that compose!

Page 44: Akka in 100 slides or less

“Functional” Futures◎ A Future is just a value, but not yet…

◎java.util.concurrent.Future is a bad Future. Akka gave us Futures that compose!

◎Composable Futures let us abstract over Future values, rather than wait for them

for {

Page 45: Akka in 100 slides or less

“Functional” Futures◎ A Future is just a value, but not yet…

◎java.util.concurrent.Future is a bad Future. Akka gave us Futures that compose!

◎Composable Futures let us abstract over Future values, rather than wait for them

for { a <- futureA()

futureA()

Page 46: Akka in 100 slides or less

futureB(a)

“Functional” Futures◎ A Future is just a value, but not yet…

◎java.util.concurrent.Future is a bad Future. Akka gave us Futures that compose!

◎Composable Futures let us abstract over Future values, rather than wait for them

for { a <- futureA() b <- futureB(a)

futureA()

Page 47: Akka in 100 slides or less

futureC(a,b) futureB(a)

“Functional” Futures◎ A Future is just a value, but not yet…

◎java.util.concurrent.Future is a bad Future. Akka gave us Futures that compose!

◎Composable Futures let us abstract over Future values, rather than wait for them

for { a <- futureA() b <- futureB(a) c <- futureC(a,b)

futureA()

Page 48: Akka in 100 slides or less

futureC(a,b) futureB(a)

“Functional” Futures◎ A Future is just a value, but not yet…

◎java.util.concurrent.Future is a bad Future. Akka gave us Futures that compose!

◎Composable Futures let us abstract over Future values, rather than wait for them

for { a <- futureA() b <- futureB(a) c <- futureC(a,b)} yield c

futureA()One

compo

sed

Future

Page 49: Akka in 100 slides or less

futureC(a,b) futureB(a)

“Functional” Futures◎ A Future is just a value, but not yet…

◎java.util.concurrent.Future is a bad Future. Akka gave us Futures that compose!

◎Composable Futures let us abstract over Future values, rather than wait for them

for { a <- futureA() b <- futureB(a) c <- futureC(a,b)} yield c

futureA()

◎Futures compose as Monads compose, which makes them “standard” functional abstractions, and that’s a powerful thing

One c

ompose

d

Future

Page 50: Akka in 100 slides or less

Abolish Callback Hell

Page 51: Akka in 100 slides or less

Abolish Callback Hellpublic void restHandler(RESTRequest req) { idservice.validate(req.userInfo, new Callback<ValidateResult>() { public void run(ValidateResult result) { if (result.isValid) { db.getProfile(req.userId, new Callback<UserProfile>() { public void run(UserProfile profile) { picServer.get(profile.pic1, new Callback<Pic>() { public void run(Pic p1) { picServer.get(profile.pic2, new Callback<Pic>() { public void run(Pic p2) { picServer.get(profile.pic3, new Callback<Pic>() { public void run(Pic p3) { picServer.get(profile.pic4, new Callback<Pic>() { public void run(Pic p4) {

picServer.get(profile.pic5, new Callback<Pic>() { public void run(Pic p5) {

twitterServer.getRecentActivity(req.userInfo, new Callback<TwitterActivity>() { public void run(TwitterActivity activity) {

req.sendResponse(pic1, pic2, pic3, pic4, pic5, activity)}

}}

}}

}}

}

Page 52: Akka in 100 slides or less

Abolish Callback Hellpublic void restHandler(RESTRequest req) { idservice.validate(req.userInfo, new Callback<ValidateResult>() { public void run(ValidateResult result) { if (result.isValid) { db.getProfile(req.userId, new Callback<UserProfile>() { public void run(UserProfile profile) { picServer.get(profile.pic1, new Callback<Pic>() { public void run(Pic p1) { picServer.get(profile.pic2, new Callback<Pic>() { public void run(Pic p2) { picServer.get(profile.pic3, new Callback<Pic>() { public void run(Pic p3) { picServer.get(profile.pic4, new Callback<Pic>() { public void run(Pic p4) {

picServer.get(profile.pic5, new Callback<Pic>() { public void run(Pic p5) {

twitterServer.getRecentActivity(req.userInfo, new Callback<TwitterActivity>() { public void run(TwitterActivity activity) {

req.sendResponse(pic1, pic2, pic3, pic4, pic5, activity)}

}}

}}

}}

}

We didn’t handle errors

We didn’t handle timeouts

It’s not necessarily Threadsafe

It’s incredibly hard to read

Page 53: Akka in 100 slides or less

Compose your Futuresimplicit val _timeout = Timeout(30.seconds) def restHandler(req: RESTRequest): Future[RESTResponse] = { val resp = for { validity <- idService.validate(req.userInfo) if validity.isValid profile <- db.getProfile(req.userId) pic1 <- picServer.get(profile.pic1) pic2 <- picServer.get(profile.pic2) pic3 <- picServer.get(profile.pic3) pic4 <- picServer.get(profile.pic4) pic5 <- picServer.get(profile.pic5) activity <- twitterServer.getRecentActivity(req.userInfo) } yield SuccessfulResponse(pic1, pic2, pic3, pic4, pic5, activity) resp recover { e: Throwable => FailedResponse(e) } }

Page 54: Akka in 100 slides or less

Compose your Futuresimplicit val _timeout = Timeout(30.seconds) def restHandler(req: RESTRequest): Future[RESTResponse] = { val resp = for { validity <- idService.validate(req.userInfo) if validity.isValid profile <- db.getProfile(req.userId) pic1 <- picServer.get(profile.pic1) pic2 <- picServer.get(profile.pic2) pic3 <- picServer.get(profile.pic3) pic4 <- picServer.get(profile.pic4) pic5 <- picServer.get(profile.pic5) activity <- twitterServer.getRecentActivity(req.userInfo) } yield SuccessfulResponse(pic1, pic2, pic3, pic4, pic5, activity) resp recover { e: Throwable => FailedResponse(e) } }

Errors have been handled

Timeouts have been handled

It’s (probably) Threadsafe

I didn’t have to shrink the font

Page 55: Akka in 100 slides or less

So why would I use Futures?

Page 56: Akka in 100 slides or less

So why would I use Futures?

Asynchronous programming is still hard⦿

Page 57: Akka in 100 slides or less

So why would I use Futures?

Asynchronous programming is still hard⦿

Programming synchronously isn’t a reasonable response⦿Thread starvation

timeoutscapacity is

suesthread thrashing

Page 58: Akka in 100 slides or less

So why would I use Futures?

Asynchronous programming is still hard⦿

Programming synchronously isn’t a reasonable response⦿

Scala Futures embody asynchronous values⦿

Thread starvation

timeoutscapacity is

suesthread thrashing

Everything is a value

Page 59: Akka in 100 slides or less

So why would I use Futures?

Asynchronous programming is still hard⦿

Programming synchronously isn’t a reasonable response⦿

Scala Futures embody asynchronous values⦿

They let us express composed asynchronous computation⦿

Thread starvation

timeoutscapacity is

suesthread thrashing

Everything is a value

Less Side Effects

Page 60: Akka in 100 slides or less

So why would I use Futures?

Asynchronous programming is still hard⦿

Programming synchronously isn’t a reasonable response⦿

Scala Futures embody asynchronous values⦿

They let us express composed asynchronous computation⦿

Futures let us propagate errors and recover from them⦿

Thread starvation

timeoutscapacity is

suesthread thrashing

Everything is a value

Less Side Effects

Graceful Failure

Resiliency

Page 61: Akka in 100 slides or less

So why would I use Futures?

Asynchronous programming is still hard⦿

Programming synchronously isn’t a reasonable response⦿

Scala Futures embody asynchronous values⦿

They let us express composed asynchronous computation⦿

Futures let us propagate errors and recover from them⦿

Asynchronous programming has always been possible but Futures now make it much more viable⦿

Thread starvation

timeoutscapacity is

suesthread thrashing

Everything is a value

Less Side Effects

Graceful Failure

Resiliency

Page 62: Akka in 100 slides or less

Operating on Data Streams

Page 63: Akka in 100 slides or less

Operating on Data Streams❉ In the real world, we communicate with things

NetworksDisks

Databases Services Slower Algorithms

Page 64: Akka in 100 slides or less

Operating on Data Streams❉ In the real world, we communicate with things

NetworksDisks

Databases Services Slower Algorithms❉ Polling sucks. We live in a real time world.

Page 65: Akka in 100 slides or less

Operating on Data Streams❉ In the real world, we communicate with things

NetworksDisks

Databases Services Slower Algorithms❉ Polling sucks. We live in a real time world.

❉ Eventing can be hard, since it doesn’t compose

Page 66: Akka in 100 slides or less

Operating on Data Streams❉ In the real world, we communicate with things

NetworksDisks

Databases Services Slower Algorithms❉ Polling sucks. We live in a real time world.

❉ Eventing can be hard, since it doesn’t compose

❉ Throttling is a real problem we never address

Page 67: Akka in 100 slides or less

Operating on Data Streams❉ In the real world, we communicate with things

NetworksDisks

Databases Services Slower Algorithms❉ Polling sucks. We live in a real time world.

❉ Eventing can be hard, since it doesn’t compose

❉ Throttling is a real problem we never address

❉ Akka Streams help us solve all of these problems

Page 68: Akka in 100 slides or less

Operating on Data Streams❉ In the real world, we communicate with things

NetworksDisks

Databases Services Slower Algorithms❉ Polling sucks. We live in a real time world.

❉ Eventing can be hard, since it doesn’t compose

❉ Throttling is a real problem we never address

❉ Akka Streams help us solve all of these problems

Source

Transformation Flow

Transformation Flow

Sink

Demand

Supply

Page 69: Akka in 100 slides or less

BackPressure is keySource

Sink

Page 70: Akka in 100 slides or less

BackPressure is key◎ Fast producers can kill; we only have so much RAM

Source

Sink

Page 71: Akka in 100 slides or less

BackPressure is key◎ Fast producers can kill; we only have so much RAM

◎ Producers can’t be artificially slow just to be nice

Source

Sink

Page 72: Akka in 100 slides or less

BackPressure is key◎ Fast producers can kill; we only have so much RAM

◎ Producers can’t be artificially slow just to be nice

◎ Consumers signal demand, Producers signal supply

Source

Sink

Page 73: Akka in 100 slides or less

BackPressure is key◎ Fast producers can kill; we only have so much RAM

◎ Producers can’t be artificially slow just to be nice

◎ Consumers signal demand, Producers signal supply

◎ When a consumer is slow, it signals no demand

Source

Sink

Page 74: Akka in 100 slides or less

BackPressure is key◎ Fast producers can kill; we only have so much RAM

◎ Producers can’t be artificially slow just to be nice

◎ Consumers signal demand, Producers signal supply

◎ When a consumer is slow, it signals no demand

◎ When a producer is slow, it doesn’t supply

Source

Sink

Page 75: Akka in 100 slides or less

BackPressure is key◎ Fast producers can kill; we only have so much RAM

◎ Producers can’t be artificially slow just to be nice

◎ Consumers signal demand, Producers signal supply

◎ When a consumer is slow, it signals no demand

◎ When a producer is slow, it doesn’t supply

Source

Sink Supply

Page 76: Akka in 100 slides or less

Composable Binary Protocols

Page 77: Akka in 100 slides or less

Composable Binary Protocols

FramerByteString ByteString

BidiFlow

SerializerObject ByteString

BidiFlow

ChunkerByteString ByteString

BidiFlow

Page 78: Akka in 100 slides or less

Composable Binary Protocols

FramerByteString ByteString

BidiFlow

SerializerObject ByteString

BidiFlow

ChunkerByteString ByteString

BidiFlow

ApplicationObject Object

Source Sink

NetworkByteString ByteString

Source SinkBidiFlow

ByteStringObject

Page 79: Akka in 100 slides or less

Composable Binary Protocols

FramerByteString ByteString

BidiFlow

SerializerObject ByteString

BidiFlow

ChunkerByteString ByteString

BidiFlow

ApplicationObject Object

Source Sink

NetworkByteString ByteString

Source SinkBidiFlow

ByteStringObject

✗Entirely reusable components that fit in any BiDirectional Flow

Page 80: Akka in 100 slides or less

Composable Binary Protocols

FramerByteString ByteString

BidiFlow

SerializerObject ByteString

BidiFlow

ChunkerByteString ByteString

BidiFlow

ApplicationObject Object

Source Sink

NetworkByteString ByteString

Source SinkBidiFlow

ByteStringObject

✗Entirely reusable components that fit in any BiDirectional Flow

✗Type safe (or as type safe as byte string marshaling gets)

Page 81: Akka in 100 slides or less

Composable Binary Protocols

FramerByteString ByteString

BidiFlow

SerializerObject ByteString

BidiFlow

ChunkerByteString ByteString

BidiFlow

ApplicationObject Object

Source Sink

NetworkByteString ByteString

Source SinkBidiFlow

ByteStringObject

✗Entirely reusable components that fit in any BiDirectional Flow

✗Type safe (or as type safe as byte string marshaling gets)

✗Entirely back pressured from end to end

Page 82: Akka in 100 slides or less

Composable Binary Protocols

FramerByteString ByteString

BidiFlow

SerializerObject ByteString

BidiFlow

ChunkerByteString ByteString

BidiFlow

ApplicationObject Object

Source Sink

NetworkByteString ByteString

Source SinkBidiFlow

ByteStringObject

✗Entirely reusable components that fit in any BiDirectional Flow

✗Type safe (or as type safe as byte string marshaling gets)

✗Entirely back pressured from end to end

✗ 100% event driven and reactive Realtime Speeds

No Blocking Threads

Natural Throttling

graceful performance degradationNot a Crash

Page 83: Akka in 100 slides or less

Why Would I use Streams?

Page 84: Akka in 100 slides or less

Why Would I use Streams?

Streaming is (probably) the crown jewel of Akka’s offering (but it’s a tough call)

Page 85: Akka in 100 slides or less

Why Would I use Streams?

Streaming is (probably) the crown jewel of Akka’s offering

The need to respond to backpressure is real and we never do it !(but it’s a tough call)

Page 86: Akka in 100 slides or less

Why Would I use Streams?

Streaming is (probably) the crown jewel of Akka’s offering

The need to respond to backpressure is real and we never do it

The need to treat our threads with respect is important

!!

(but it’s a tough call)

Page 87: Akka in 100 slides or less

Why Would I use Streams?

Streaming is (probably) the crown jewel of Akka’s offering

The need to respond to backpressure is real and we never do it

The need to treat our threads with respect is important

The need to be reactive and fast is vital to the user experience

!!!

(but it’s a tough call)

Page 88: Akka in 100 slides or less

Why Would I use Streams?

Streaming is (probably) the crown jewel of Akka’s offering

The need to respond to backpressure is real and we never do it

The need to treat our threads with respect is important

The need to be reactive and fast is vital to the user experience

Streams give us all of this and let us use our hardware to its fullest

!!!

! ! !

(but it’s a tough call)

Page 89: Akka in 100 slides or less

Akka from 20k feetAkka from 20k feet

Page 90: Akka in 100 slides or less

Akka from 20k feetAkka from 20k feet

Actors!Actors!Live Objects

Supervised

AsynchronousMessage Passing

ServicesState Machines

Network Ready

Page 91: Akka in 100 slides or less

Akka from 20k feetAkka from 20k feet

Actors!Actors!

Futures!Futures!

Live Objects

Supervised

AsynchronousMessage Passing

ServicesState Machines

Network Ready

Composable Values

ReactiveMonadic

Immutable

Threadsafe

Work Well with Actors

Page 92: Akka in 100 slides or less

Akka from 20k feetAkka from 20k feet

Actors!Actors!

Futures!Futures!

Streams!Streams!

Live Objects

Supervised

AsynchronousMessage Passing

ServicesState Machines

Network Ready

Composable Values

ReactiveMonadic

Immutable

Threadsafe

Work Well with Actors

BackPressured

Composable

Reusable

Event DrivenFlexible

Lots of Activity and Support

Work with Futures and Actors

Page 93: Akka in 100 slides or less

Go Get AKKA!Go Get AKKA!Website: http://akka.io

Scala Reference: http://doc.akka.io/docs/akka/current/scala.html

Java Reference: http://doc.akka.io/docs/akka/current/java.html

Streams Reference: http://doc.akka.io/docs/akka-stream-and-http-experimental/current/scala.html

Derek Wyatt Twitter: @derekwyatt

Email: [email protected] 2015