59
@petabridge Petabridge.com Concurrency Without the Pain An Intro to Akka.NET & Actor Model #AkkaDotNet @ #LDNUG Andrew Skotzko Cofounder — Petabridge

Akka.NET @ London.NET

Embed Size (px)

Citation preview

@petabridge Petabridge.com

Concurrency Without the Pain

An Intro to Akka.NET & Actor Model

#AkkaDotNet @ #LDNUG

Andrew  Skotzko  Co-­‐founder  —  Petabridge  

@petabridge Petabridge.com

Why  should  we  care  about  

concurrency?  

@petabridge Petabridge.com

1970  -­‐  2005  

@petabridge Petabridge.com

@petabridge Petabridge.com

@petabridge Petabridge.com

@petabridge Petabridge.com

@petabridge Petabridge.com

@petabridge Petabridge.com

@petabridge Petabridge.com

TANSTAAFL  “There  ain’t  no  such  thing  as  a  free  lunch.”  —R.  A.  Heinlein,  The  Moon  Is  a  Harsh  Mistress  

@petabridge Petabridge.com

What  the  hell  are  you  talking  about?  

@petabridge Petabridge.com

Concurrency.  

We  needs  it.  

@petabridge Petabridge.com

So  why  is  this  hard?  

@petabridge Petabridge.com

How to Write Multithreaded Code

@petabridge Petabridge.com

Shared State Programming Sucks (Illustrated)

@petabridge Petabridge.com

Random?

•  .NET 4.0: TPL (2010) •  .NET 4.5: async/await (2012)

@petabridge Petabridge.com

Is there a better way? THERE MUST BE! THERE.  MUST.  BE.  A.  BETTER.  WAY!  

@petabridge Petabridge.com

Warning! Mind Blowingly Different

Programming Style Ahead!

@petabridge Petabridge.com

Warning! Mind Blowingly Different Programming Style Ahead!

@petabridge Petabridge.com

The Actor Model

@petabridge Petabridge.com

What  is  the  actor  model?  

@petabridge Petabridge.com

Everything  is  an  actor.  

@petabridge Petabridge.com

@petabridge Petabridge.com

@petabridge Petabridge.com

3 Core Abilities

1.  Send  messages  2. Create  other  actors  3. Change  behavior  

@petabridge Petabridge.com

Messages

@petabridge Petabridge.com

Actors work by passing each other messages

@petabridge Petabridge.com

Message passing in action

@petabridge Petabridge.com

BUZZWORD  BINGO!  

@petabridge Petabridge.com

Example Akka.NET Message

@petabridge Petabridge.com

Actors send messages to addresses

@petabridge Petabridge.com

Actor addresses have location transparency

@petabridge Petabridge.com

Which means…

@petabridge Petabridge.com

@petabridge Petabridge.com

@petabridge Petabridge.com

ReactiveManifesto.org

@petabridge Petabridge.com

What is Akka.NET?

@petabridge Petabridge.com

Battle-Tested (JVM)

@petabridge Petabridge.com

This is an actor

@petabridge Petabridge.com

These are messages

@petabridge Petabridge.com

Actors run on threads

@petabridge Petabridge.com

Actors are lazy

@petabridge Petabridge.com

Process messages one at a time

@petabridge Petabridge.com

The circle of life

@petabridge Petabridge.com

@petabridge Petabridge.com

Hierarchies

@petabridge Petabridge.com

Supervision

@petabridge Petabridge.com

Switchable Behavior

@petabridge Petabridge.com

And Can Form Highly Available Systems

@petabridge Petabridge.com

What’s  this  give  me?  

@petabridge Petabridge.com

Where can I use this? •  Analytics systems •  Marketing automation •  Multi-player games •  Device / IoT tracking •  Alerting & monitoring systems •  Recommendation engines •  Dynamic pricing •  Microservices •  Reactive UI

@petabridge Petabridge.com

DEMO  

@petabridge Petabridge.com

hZp://LearnAkka.net  

@petabridge Petabridge.com

THANK YOU!

Email:  [email protected]    

TwiZerz:    @askotzko  

@AkkaDotNet  

@petabridge Petabridge.com

Hierarchies pt. deux

@petabridge Petabridge.com

Character Actor Pattern

@petabridge Petabridge.com

ActorSelection == selection by address

@petabridge Petabridge.com

Actor lifecycle

@petabridge Petabridge.com

Actor lifecycle