What is the actor model

Post on 13-Apr-2017

252 views 0 download

transcript

William BranderWhat is the Actor Model? A glance using Akka.NET

Tools & Frameworks

>What is The Actor Model

>Intro to Akka.NET

>What to do when things go wrong

Agenda

But first… a concurrency recap

$50$70

Current balance: $70

Request $50Check Balance

Balance GoodBalance Good Current

balance: $20Request $70 Check BalanceBalance Bad

Balance Bad

Request $50Check Balance

Request $70Balance Good

Check BalanceBalance Good

Balance Good Current balance: $20

Balance Good

Current balance: -$50

Concurrency is hard

Demo: Flawed concurrent processing

Concurrency is hard>Code loses intent>It’s even harder across application boundaries>Are there situations you’ve missed?

>And how many of you noticed that the code was wrong?

if (CanDraw(amount)){ if (CanDraw(amount)) { lock (_lock) { ///... } }}

lock (_lock){ if (CanDraw(amount)) {

if (CanDraw(amount)) { ///... } }}

The Actor Model

Behaviour Concurrency State Mailbox

The Actor Model>Actors are objects that operate concurrently>Actors maintain their own state>Actors communicate via message passing>Actors have behaviour>Actors have an address but not a location

Demo: Akka.NET

Akka.NET>.NET port of Akka>Handles concurrency, messaging, and location

transparency>At most once delivery

Is the network reliable?>Well sure. Mostly. Sometimes.>It is, until it’s not.The network is NOT

reliableAnd neither is your

application code

Demo: Presenting a fallacy

Things go wrong>What’s important is to never lose messages

>Supervisors can monitor for failures

>Embrace the Dead Letter Queue

Alternatives>Orleans>Akka>Remact.Net

>Other Patterns?• Process Control

Suggested reading>http://www.enterpriseintegrationpatterns.com/

>Why has the Actor Model not succeeded?

>Finding Service Boundaries (video)

>Dr. Harvey and the 8 Fallacies of Distributed Computing (http://bit.ly/WBZAdev)

>Udi Dahan’s Advanced Distributed Systems Design Course (http://go.particular.net/SA2016, code: 1yC70)

/* THANK YOU*/William BranderParticular SoftwareWilliam.brander@particular.net@WilliamBZA

http://www.devconf.co.za/