SlideShare a Scribd company logo
akka.net
soeren.stelzer@clear-it.de
Reactive Manifest und Akka.Net
Wie kommen wir da hin? Reactive Manifesto
event Handling data flow graph processing
System Architecure
zuverlässige skalierbare
elastic
message-driven
resilient
responsive
http://www.reactivemanifesto.org/de
Elastic
react to load
Message-Driven
Services / Components Interaction
Resilient
react to failures
Responsive
react to users
Reactive System
goal
methods
concepts
resilient elastic
Up Out
Down In
at first, dry theory…
Carl Hewitt (1973),
Actor Model of Computation:
Scalable Robust Information Systems
…jetzt.
• Typesafe: Actor-Framework
• Scala (JVM) => Java
• ausgereiftes, erprobtes Framework
• Akka.Net
• Portierung von Akka (2013)
• Aaron Stannard Roger Johansson
• http://getakka.net
akka.net
Concurreny
 Scalability
 Fault-tolerance
Simpler
 Programming Model
 Managed Runtime
 Open Source Distribution
…with a single unified
Scale UP
Scale OUT
http://doc.akka.io/docs/akka/current/intro/use-cases.html
PM> Install-Package Akka
nuget
using Akka.Actor;
using (var actorSystem = ActorSystem.Create("MyActorSystem"))
{
// universe
}
nur innerhalb dieses Blocks
„leben“ Aktoren
var actorSystem = ActorSystem.Create("MyActorSystem"));
// universe
actorSystem.WhenTerminated.Wait(); // wait for termination-task
actorSystem.AwaitTermination(); // deprecated
oder
// universe
IActorRef myActor = actorSystem.ActorOf(
Props.Create(() => new MyActor())
);
using (var actorSystem = ActorSystem.Create("MyActorSystem"))
{
}
// talk to the actor
myActor.Tell(new SomeMessage("rise up slave..."));
erzeuge AktorSystem
fordere spezifischen
Aktor an
sprich mit dem erhaltenen
Aktor
public class SomeMessage
{
public SomeMessage(string name)
{
Name = name;
}
public string Name { get; private set; }
}
public class MyActor : ReceiveActor
{
public MyActor()
{
Receive<string>(message => {
Sender.Tell(message);
});
Receive<SomeMessage>(message => {
// react to message
});
}
}
alle Nachrichten sind
immutable
Nachrichten werden
prinzipiell nach ihrem
Typ unterschieden *
* es geht fein-granularer
und abstrakter
Receive<string>(s => Console.WriteLine("Received string: " + s)); //1
Receive<int>(i => Console.WriteLine("Received integer: " + i)); //2
IActorRef sender = Sender;
//Receive using Funcs
Receive<string>(s =>
{
if (s.Length > 5) {
Console.WriteLine("1: " + s);
return true;
}
return false;
});
Receive<string>(s => Console.WriteLine("2: " + s));
//predicates
Receive<string>(s => s.Length > 5, s => Console.WriteLine("1: " + s)); //1
Receive<string>(s => s.Length > 2, s => Console.WriteLine("2: " + s)); //2
Receive<string>(s => Console.WriteLine("3: " + s));
//handler priority
Receive<string>(s => s.Length > 5, s => Console.WriteLine("1: " + s)); //1
Receive<string>(s => s.Length > 2, s => Console.WriteLine("2: " + s)); //2
Receive<string>(s => Console.WriteLine("3: " + s)); //3
public class MyActor : ActorBase
{
public MyActor()
{
//nothing todo
}
protected override bool Receive(object _message)
{
//handle different messages
var message = _message as SomeMessage;
if(message != null)
{
return false;
}
return false;
}
}
Nachrichten werden
prinzipiell nach ihrem
Typ unterschieden *
* es geht fein-granularer
und abstrakter
using Akka.Actor;
public class MyUntypedActor : UntypedActor
{
protected override void OnReceive(object message)
{
var msg = message as Messages.InputError;
if (msg != null)
{
// cool, its for me
}
else
{
Unhandled(message); //from ActorBase
}
}
}
• anders als beim ReceiveActor müssen nicht behandelte
Nachrichten selbst als solche markiert werden
IActorRef friend = Context.ActorOf(Props.Create(() => new MyReceiveActor()));
sender.Tell(new SomeMessage("Re: " + message.Name));
IActorRef friend = ...
friend.Tell(new SomeMessage("Forward: " + message.Name), sender);
IActorRef friend = ...
friend.Forward(new SomeMessage("Forward: " + message.Name)); forward
tell + explicit sender
tell
Nicht die da, andere….
event-driven thread
Actor
Behavior
Mailbox
State
Childs
Supervisor-Strategy
ActorRef 1 2 34
Transport [Akka]
IActorRef myActor = ...
myActor.Tell(new Message("four"));
• IActorRef: handle oder reference auf einen Actor
• Nachrichten werden niemals direkt an einen
Actor gesendet
• ActorSystem fügt Metadaten (Sender, Empfänger) hinzu
• ActorSystem garantiert Ankunft jeder Nachricht *
IActorRef
• Actor Namen sind optional
• best practise: named actors
Create
Look up
IActorRef myActor = actorSystem.ActorOf(
Props.Create(() => new MyActor()),
"myactor1"
);
• adressierbar über ActorPath
• Actoren bilden eine Hierarchy
Parent
Children
Sender
ActorSelection randomActor =
actorSystem.ActorSelection("akka://ActorSys/user/myactor1");
Props props1 = Props.Create(typeof(MyActor));
Props props2 = Props.Create(() => new MyActor());
Props props3 = Props.Create<MyActor>();
typeof Syntax
lambda Syntax
generic Syntax
• einzigerWeg um Parameter
zu übergeben
• unsicher
Context.ActorOf(props2);
actorSystem.ActorOf(props2);
aus einem Actor heraus:
direkt im ActorSystem:
-> erzeugt HierarchieVerwendung
akka.tcp://MySystem@localhost:9001/user/actorName1
Protocol
ActorSystem
Akka
Path
Akka Remote
Address
/syst
em
Guardians
/a1 /a2
top level
actor
/b1
/c1 /cx
/b2
/c2 /cx
akka://ActorSystem/user
akka://ActorSystem/user/a1
akka://ActorSystem/user/a1/b2
akka://ActorSystem/user/a1/*/cx
/user
/
parent
parent
Failure
SupervisionStrategy
• Restart, Stop, Resume, Escalate
• 2 Default-Strategien: One-For-One und All-For-One
• erklärtes Ziel ist es Fehler einzugrenzen:
• localizing the failure: fehleranfälligen Code
The critical thing to know here is that *whatever action is
taken on a parent propagates to its children*. If a parent is
halted, all its children halt. If it is restarted, all its children
restart.
protected override SupervisorStrategy SupervisorStrategy() {
// immer die gleiche Entscheidung
return new OneForOneStrategy(
maxNrOfRetries: 10,
withinTimeRange: TimeSpan.FromSeconds(30),
localOnlyDecider: exception =>
{
Console.WriteLine("*** Supervision: Restart");
return Directive.Restart;
}
);
}
Clients
[SignalR]
Clients
[SignalR]
Clients
[SignalR]
GameHub
[SignalR]
Bridge-
Actor
[Akka]
GameCtrl-
Actor
[Akka]
Player-
Actor
[Akka]
internet
join
attack attack
refreshState
sendState
changeHealth
join
attack
Clients
[SignalR]
Clients
[SignalR]
Clients
[SignalR]
GameHub
[SignalR]
internet
join
attack
ActorSystem
[Akka]
public class MvcApplication : HttpApplication {
protected void Application_Start()
{
//ASP.Net Stuff: Filters, Routes, ...
//Akka init
GameActorSystem.Create();
}
void Application_End()
{
GameActorSystem.Shutdown();
}
}
public static class GameActorSystem
{
private static ActorSystem ActorSystem;
private static IGameEventsPusher _gameEventsPusher;
public static void Create()
{
_gameEventsPusher = new SignalRGameEventPusher();
ActorSystem = Akka.Actor.ActorSystem.Create("GameSystem");
ActorReferences.GameController = ActorSystem.ActorOf<GameControllerActor>();
ActorReferences.SignalRBridge = ActorSystem.ActorOf(
Props.Create(() =>
new SignalRBridgeActor(_gameEventsPusher, ActorReferences.GameController)),
"SignalRBridge„
);
}
public static void Shutdown()
{
ActorSystem.Shutdown();
ActorSystem.AwaitTermination(TimeSpan.FromSeconds(1));
}
public static class ActorReferences ...
}
class SignalRGameEventPusher : IGameEventsPusher {
private static readonly IHubContext _gameHubContext;
static SignalRGameEventPusher() //static CTOR
{
_gameHubContext = GlobalHost.ConnectionManager.GetHubContext<GameHub>();
}
public void PlayerJoined(string playerName, int playerHealth)
{
_gameHubContext.Clients.All.playerJoined(playerName, playerHealth);
}
public void UpdatePlayerHealth(string playerName, int playerHealth)
{
_gameHubContext.Clients.All.updatePlayerHealth(playerName, playerHealth);
}
}
GameHub
[SignalR]
ActorSystem
[Akka]
playerJoined
updatePlayerHealth
Clients
Clients
Clients
public class GameHub : Hub
{
public void JoinGame(string playerName)
{
GameActorSystem
.ActorReferences
.SignalRBridge
.Tell(new JoinGameMessage(playerName));
}
public void Attack(string playerName)
{
GameActorSystem
.ActorReferences
.SignalRBridge
.Tell(new AttackPlayerMessage(playerName));
}
}
GameHub
[SignalR]
join
attack
ActorSystem
[Akka]
Closed
Open
Deleted
open close
delete

More Related Content

What's hot

Serverless lessons learned #2 dead letter queues
Serverless lessons learned #2 dead letter queuesServerless lessons learned #2 dead letter queues
Serverless lessons learned #2 dead letter queues
Maik Wiesmüller
 
Greenfield Development with CQRS
Greenfield Development with CQRSGreenfield Development with CQRS
Greenfield Development with CQRS
David Hoerster
 
Serverless lessons learned #3 reserved concurrency
Serverless lessons learned #3 reserved concurrencyServerless lessons learned #3 reserved concurrency
Serverless lessons learned #3 reserved concurrency
Maik Wiesmüller
 
Serverless lessons learned #5 retries
Serverless lessons learned #5 retriesServerless lessons learned #5 retries
Serverless lessons learned #5 retries
Maik Wiesmüller
 
Anatomy of a high-volume, cloud-based WordPress architecture
Anatomy of a high-volume, cloud-based WordPress architectureAnatomy of a high-volume, cloud-based WordPress architecture
Anatomy of a high-volume, cloud-based WordPress architectureGabriel Koen
 
Serverless lessons learned #1 custom sdk timeouts
Serverless lessons learned #1 custom sdk timeoutsServerless lessons learned #1 custom sdk timeouts
Serverless lessons learned #1 custom sdk timeouts
Maik Wiesmüller
 
Local development using telepresence
Local development using telepresenceLocal development using telepresence
Local development using telepresence
Irvi Aini
 
How Postman adopted Docker
How Postman adopted DockerHow Postman adopted Docker
How Postman adopted Docker
Shamasis Bhattacharya
 
Continuous Delivery in Java
Continuous Delivery in JavaContinuous Delivery in Java
Continuous Delivery in Java
XPeppers
 
Serverless lessons learned #8 backoff
Serverless lessons learned #8 backoffServerless lessons learned #8 backoff
Serverless lessons learned #8 backoff
Maik Wiesmüller
 
Serverless lessons learned #4 circuit breaker
Serverless lessons learned #4 circuit breakerServerless lessons learned #4 circuit breaker
Serverless lessons learned #4 circuit breaker
Maik Wiesmüller
 
Elixir – Peeking into Elixir's Processes, OTP and Supervisors
Elixir – Peeking into Elixir's Processes, OTP and SupervisorsElixir – Peeking into Elixir's Processes, OTP and Supervisors
Elixir – Peeking into Elixir's Processes, OTP and SupervisorsBenjamin Tan
 
Akka - A Brief Intro
Akka - A Brief IntroAkka - A Brief Intro
Akka - A Brief Intro
Thomas Lockney
 
Akka.net versus microsoft orleans
Akka.net versus microsoft orleansAkka.net versus microsoft orleans
Akka.net versus microsoft orleans
Bill Tulloch
 
How Elixir helped us scale our Video User Profile Service for the Olympics
How Elixir helped us scale our Video User Profile Service for the OlympicsHow Elixir helped us scale our Video User Profile Service for the Olympics
How Elixir helped us scale our Video User Profile Service for the Olympics
Emerson Macedo
 
Actor model in F# and Akka.NET
Actor model in F# and Akka.NETActor model in F# and Akka.NET
Actor model in F# and Akka.NET
Riccardo Terrell
 
Empower every Azure Function to achieve more!!
Empower every Azure Function to achieve more!!Empower every Azure Function to achieve more!!
Empower every Azure Function to achieve more!!
Massimo Bonanni
 
AWS Lambda from the trenches
AWS Lambda from the trenchesAWS Lambda from the trenches
AWS Lambda from the trenches
Yan Cui
 
Serverless lessons learned #7 rate limiting
Serverless lessons learned #7 rate limitingServerless lessons learned #7 rate limiting
Serverless lessons learned #7 rate limiting
Maik Wiesmüller
 
Vera: How I WiFi Enabled My Coffee Pot
Vera: How I WiFi Enabled My Coffee PotVera: How I WiFi Enabled My Coffee Pot
Vera: How I WiFi Enabled My Coffee Pot
Tyler Petresky
 

What's hot (20)

Serverless lessons learned #2 dead letter queues
Serverless lessons learned #2 dead letter queuesServerless lessons learned #2 dead letter queues
Serverless lessons learned #2 dead letter queues
 
Greenfield Development with CQRS
Greenfield Development with CQRSGreenfield Development with CQRS
Greenfield Development with CQRS
 
Serverless lessons learned #3 reserved concurrency
Serverless lessons learned #3 reserved concurrencyServerless lessons learned #3 reserved concurrency
Serverless lessons learned #3 reserved concurrency
 
Serverless lessons learned #5 retries
Serverless lessons learned #5 retriesServerless lessons learned #5 retries
Serverless lessons learned #5 retries
 
Anatomy of a high-volume, cloud-based WordPress architecture
Anatomy of a high-volume, cloud-based WordPress architectureAnatomy of a high-volume, cloud-based WordPress architecture
Anatomy of a high-volume, cloud-based WordPress architecture
 
Serverless lessons learned #1 custom sdk timeouts
Serverless lessons learned #1 custom sdk timeoutsServerless lessons learned #1 custom sdk timeouts
Serverless lessons learned #1 custom sdk timeouts
 
Local development using telepresence
Local development using telepresenceLocal development using telepresence
Local development using telepresence
 
How Postman adopted Docker
How Postman adopted DockerHow Postman adopted Docker
How Postman adopted Docker
 
Continuous Delivery in Java
Continuous Delivery in JavaContinuous Delivery in Java
Continuous Delivery in Java
 
Serverless lessons learned #8 backoff
Serverless lessons learned #8 backoffServerless lessons learned #8 backoff
Serverless lessons learned #8 backoff
 
Serverless lessons learned #4 circuit breaker
Serverless lessons learned #4 circuit breakerServerless lessons learned #4 circuit breaker
Serverless lessons learned #4 circuit breaker
 
Elixir – Peeking into Elixir's Processes, OTP and Supervisors
Elixir – Peeking into Elixir's Processes, OTP and SupervisorsElixir – Peeking into Elixir's Processes, OTP and Supervisors
Elixir – Peeking into Elixir's Processes, OTP and Supervisors
 
Akka - A Brief Intro
Akka - A Brief IntroAkka - A Brief Intro
Akka - A Brief Intro
 
Akka.net versus microsoft orleans
Akka.net versus microsoft orleansAkka.net versus microsoft orleans
Akka.net versus microsoft orleans
 
How Elixir helped us scale our Video User Profile Service for the Olympics
How Elixir helped us scale our Video User Profile Service for the OlympicsHow Elixir helped us scale our Video User Profile Service for the Olympics
How Elixir helped us scale our Video User Profile Service for the Olympics
 
Actor model in F# and Akka.NET
Actor model in F# and Akka.NETActor model in F# and Akka.NET
Actor model in F# and Akka.NET
 
Empower every Azure Function to achieve more!!
Empower every Azure Function to achieve more!!Empower every Azure Function to achieve more!!
Empower every Azure Function to achieve more!!
 
AWS Lambda from the trenches
AWS Lambda from the trenchesAWS Lambda from the trenches
AWS Lambda from the trenches
 
Serverless lessons learned #7 rate limiting
Serverless lessons learned #7 rate limitingServerless lessons learned #7 rate limiting
Serverless lessons learned #7 rate limiting
 
Vera: How I WiFi Enabled My Coffee Pot
Vera: How I WiFi Enabled My Coffee PotVera: How I WiFi Enabled My Coffee Pot
Vera: How I WiFi Enabled My Coffee Pot
 

Viewers also liked

Building responsive applications with Rx - CodeMash2017 - Tamir Dresher
Building responsive applications with Rx  - CodeMash2017 - Tamir DresherBuilding responsive applications with Rx  - CodeMash2017 - Tamir Dresher
Building responsive applications with Rx - CodeMash2017 - Tamir Dresher
Tamir Dresher
 
Drm and the web
Drm and the webDrm and the web
Drm and the web
Anthony Brown
 
Intro to RX
Intro to RXIntro to RX
Intro to RX
Scott Weinstein
 
Distributed Transactions in Akka.NET
Distributed Transactions in Akka.NETDistributed Transactions in Akka.NET
Distributed Transactions in Akka.NET
petabridge
 
From Zero to the Actor Model (With Akka.Net) - CodeMash2017 - Tamir Dresher
From Zero to the Actor Model (With Akka.Net) - CodeMash2017 - Tamir DresherFrom Zero to the Actor Model (With Akka.Net) - CodeMash2017 - Tamir Dresher
From Zero to the Actor Model (With Akka.Net) - CodeMash2017 - Tamir Dresher
Tamir Dresher
 
Reactive Development: Commands, Actors and Events. Oh My!!
Reactive Development: Commands, Actors and Events.  Oh My!!Reactive Development: Commands, Actors and Events.  Oh My!!
Reactive Development: Commands, Actors and Events. Oh My!!
David Hoerster
 
CQRS Evolved - CQRS + Akka.NET
CQRS Evolved - CQRS + Akka.NETCQRS Evolved - CQRS + Akka.NET
CQRS Evolved - CQRS + Akka.NET
David Hoerster
 
Online game server on Akka.NET (NDC2016)
Online game server on Akka.NET (NDC2016)Online game server on Akka.NET (NDC2016)
Online game server on Akka.NET (NDC2016)
Esun Kim
 
CQRS and Event Sourcing, An Alternative Architecture for DDD
CQRS and Event Sourcing, An Alternative Architecture for DDDCQRS and Event Sourcing, An Alternative Architecture for DDD
CQRS and Event Sourcing, An Alternative Architecture for DDD
Dennis Doomen
 

Viewers also liked (9)

Building responsive applications with Rx - CodeMash2017 - Tamir Dresher
Building responsive applications with Rx  - CodeMash2017 - Tamir DresherBuilding responsive applications with Rx  - CodeMash2017 - Tamir Dresher
Building responsive applications with Rx - CodeMash2017 - Tamir Dresher
 
Drm and the web
Drm and the webDrm and the web
Drm and the web
 
Intro to RX
Intro to RXIntro to RX
Intro to RX
 
Distributed Transactions in Akka.NET
Distributed Transactions in Akka.NETDistributed Transactions in Akka.NET
Distributed Transactions in Akka.NET
 
From Zero to the Actor Model (With Akka.Net) - CodeMash2017 - Tamir Dresher
From Zero to the Actor Model (With Akka.Net) - CodeMash2017 - Tamir DresherFrom Zero to the Actor Model (With Akka.Net) - CodeMash2017 - Tamir Dresher
From Zero to the Actor Model (With Akka.Net) - CodeMash2017 - Tamir Dresher
 
Reactive Development: Commands, Actors and Events. Oh My!!
Reactive Development: Commands, Actors and Events.  Oh My!!Reactive Development: Commands, Actors and Events.  Oh My!!
Reactive Development: Commands, Actors and Events. Oh My!!
 
CQRS Evolved - CQRS + Akka.NET
CQRS Evolved - CQRS + Akka.NETCQRS Evolved - CQRS + Akka.NET
CQRS Evolved - CQRS + Akka.NET
 
Online game server on Akka.NET (NDC2016)
Online game server on Akka.NET (NDC2016)Online game server on Akka.NET (NDC2016)
Online game server on Akka.NET (NDC2016)
 
CQRS and Event Sourcing, An Alternative Architecture for DDD
CQRS and Event Sourcing, An Alternative Architecture for DDDCQRS and Event Sourcing, An Alternative Architecture for DDD
CQRS and Event Sourcing, An Alternative Architecture for DDD
 

Similar to Reactive Programming in .Net - actorbased computing with Akka.Net

Akka Actors: an Introduction
Akka Actors: an IntroductionAkka Actors: an Introduction
Akka Actors: an Introduction
Roberto Casadei
 
Scaling Web Apps with Akka
Scaling Web Apps with AkkaScaling Web Apps with Akka
Scaling Web Apps with AkkaMaciej Matyjas
 
Akka lsug skills matter
Akka lsug skills matterAkka lsug skills matter
Akka lsug skills matter
Skills Matter
 
Akka london scala_user_group
Akka london scala_user_groupAkka london scala_user_group
Akka london scala_user_groupSkills Matter
 
Activator and Reactive at Play NYC meetup
Activator and Reactive at Play NYC meetupActivator and Reactive at Play NYC meetup
Activator and Reactive at Play NYC meetup
Henrik Engström
 
First glance at Akka 2.0
First glance at Akka 2.0First glance at Akka 2.0
First glance at Akka 2.0
Vasil Remeniuk
 
Building Stateful Microservices With Akka
Building Stateful Microservices With AkkaBuilding Stateful Microservices With Akka
Building Stateful Microservices With Akka
Yaroslav Tkachenko
 
Introduction to Actor Model and Akka
Introduction to Actor Model and AkkaIntroduction to Actor Model and Akka
Introduction to Actor Model and AkkaYung-Lin Ho
 
Akka Remoting and Clustering: an Introduction
Akka Remoting and Clustering: an IntroductionAkka Remoting and Clustering: an Introduction
Akka Remoting and Clustering: an Introduction
Roberto Casadei
 
Akka Microservices Architecture And Design
Akka Microservices Architecture And DesignAkka Microservices Architecture And Design
Akka Microservices Architecture And Design
Yaroslav Tkachenko
 
Networks and types - the future of Akka
Networks and types - the future of AkkaNetworks and types - the future of Akka
Networks and types - the future of Akka
Johan Andrén
 
Introduction to Akka - Atlanta Java Users Group
Introduction to Akka - Atlanta Java Users GroupIntroduction to Akka - Atlanta Java Users Group
Introduction to Akka - Atlanta Java Users Group
Roy Russo
 
Developing distributed applications with Akka and Akka Cluster
Developing distributed applications with Akka and Akka ClusterDeveloping distributed applications with Akka and Akka Cluster
Developing distributed applications with Akka and Akka Cluster
Konstantin Tsykulenko
 
Introduction to Apache Mesos
Introduction to Apache MesosIntroduction to Apache Mesos
Introduction to Apache Mesos
Joe Stein
 
Building Massively Scalable application with Akka 2.0
Building Massively Scalable application with Akka 2.0Building Massively Scalable application with Akka 2.0
Building Massively Scalable application with Akka 2.0
Knoldus Inc.
 
What`s new in Java 7
What`s new in Java 7What`s new in Java 7
What`s new in Java 7
Georgian Micsa
 
Akka Cluster in Java - JCConf 2015
Akka Cluster in Java - JCConf 2015Akka Cluster in Java - JCConf 2015
Akka Cluster in Java - JCConf 2015
Jiayun Zhou
 
Akka and futures
Akka and futuresAkka and futures
Akka and futures
Knoldus Inc.
 
Akka (BeJUG)
Akka (BeJUG)Akka (BeJUG)

Similar to Reactive Programming in .Net - actorbased computing with Akka.Net (20)

Akka Actors: an Introduction
Akka Actors: an IntroductionAkka Actors: an Introduction
Akka Actors: an Introduction
 
Scaling Web Apps with Akka
Scaling Web Apps with AkkaScaling Web Apps with Akka
Scaling Web Apps with Akka
 
Akka lsug skills matter
Akka lsug skills matterAkka lsug skills matter
Akka lsug skills matter
 
Akka london scala_user_group
Akka london scala_user_groupAkka london scala_user_group
Akka london scala_user_group
 
Activator and Reactive at Play NYC meetup
Activator and Reactive at Play NYC meetupActivator and Reactive at Play NYC meetup
Activator and Reactive at Play NYC meetup
 
First glance at Akka 2.0
First glance at Akka 2.0First glance at Akka 2.0
First glance at Akka 2.0
 
Building Stateful Microservices With Akka
Building Stateful Microservices With AkkaBuilding Stateful Microservices With Akka
Building Stateful Microservices With Akka
 
Introduction to Actor Model and Akka
Introduction to Actor Model and AkkaIntroduction to Actor Model and Akka
Introduction to Actor Model and Akka
 
Akka Remoting and Clustering: an Introduction
Akka Remoting and Clustering: an IntroductionAkka Remoting and Clustering: an Introduction
Akka Remoting and Clustering: an Introduction
 
Akka Microservices Architecture And Design
Akka Microservices Architecture And DesignAkka Microservices Architecture And Design
Akka Microservices Architecture And Design
 
Networks and types - the future of Akka
Networks and types - the future of AkkaNetworks and types - the future of Akka
Networks and types - the future of Akka
 
Introduction to Akka - Atlanta Java Users Group
Introduction to Akka - Atlanta Java Users GroupIntroduction to Akka - Atlanta Java Users Group
Introduction to Akka - Atlanta Java Users Group
 
Developing distributed applications with Akka and Akka Cluster
Developing distributed applications with Akka and Akka ClusterDeveloping distributed applications with Akka and Akka Cluster
Developing distributed applications with Akka and Akka Cluster
 
Introduction to Apache Mesos
Introduction to Apache MesosIntroduction to Apache Mesos
Introduction to Apache Mesos
 
Building Massively Scalable application with Akka 2.0
Building Massively Scalable application with Akka 2.0Building Massively Scalable application with Akka 2.0
Building Massively Scalable application with Akka 2.0
 
What`s new in Java 7
What`s new in Java 7What`s new in Java 7
What`s new in Java 7
 
Akka Cluster in Java - JCConf 2015
Akka Cluster in Java - JCConf 2015Akka Cluster in Java - JCConf 2015
Akka Cluster in Java - JCConf 2015
 
Akka and futures
Akka and futuresAkka and futures
Akka and futures
 
JS everywhere 2011
JS everywhere 2011JS everywhere 2011
JS everywhere 2011
 
Akka (BeJUG)
Akka (BeJUG)Akka (BeJUG)
Akka (BeJUG)
 

Recently uploaded

Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
ThousandEyes
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
Alison B. Lowndes
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
Sri Ambati
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
Peter Spielvogel
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
DianaGray10
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
ControlCase
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
BookNet Canada
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
Ralf Eggert
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Paige Cruz
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
RinaMondal9
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.
ViralQR
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
OnBoard
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
nkrafacyberclub
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance
 

Recently uploaded (20)

Assuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyesAssuring Contact Center Experiences for Your Customers With ThousandEyes
Assuring Contact Center Experiences for Your Customers With ThousandEyes
 
Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........Bits & Pixels using AI for Good.........
Bits & Pixels using AI for Good.........
 
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
GenAISummit 2024 May 28 Sri Ambati Keynote: AGI Belongs to The Community in O...
 
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdfSAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
SAP Sapphire 2024 - ASUG301 building better apps with SAP Fiori.pdf
 
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4UiPath Test Automation using UiPath Test Suite series, part 4
UiPath Test Automation using UiPath Test Suite series, part 4
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
PCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase TeamPCI PIN Basics Webinar from the Controlcase Team
PCI PIN Basics Webinar from the Controlcase Team
 
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...Transcript: Selling digital books in 2024: Insights from industry leaders - T...
Transcript: Selling digital books in 2024: Insights from industry leaders - T...
 
PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)PHP Frameworks: I want to break free (IPC Berlin 2024)
PHP Frameworks: I want to break free (IPC Berlin 2024)
 
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdfObservability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
Observability Concepts EVERY Developer Should Know -- DeveloperWeek Europe.pdf
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
Free Complete Python - A step towards Data Science
Free Complete Python - A step towards Data ScienceFree Complete Python - A step towards Data Science
Free Complete Python - A step towards Data Science
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.Welocme to ViralQR, your best QR code generator.
Welocme to ViralQR, your best QR code generator.
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Leading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdfLeading Change strategies and insights for effective change management pdf 1.pdf
Leading Change strategies and insights for effective change management pdf 1.pdf
 
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptxSecstrike : Reverse Engineering & Pwnable tools for CTF.pptx
Secstrike : Reverse Engineering & Pwnable tools for CTF.pptx
 
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdfFIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
FIDO Alliance Osaka Seminar: Passkeys at Amazon.pdf
 

Reactive Programming in .Net - actorbased computing with Akka.Net

  • 4. Wie kommen wir da hin? Reactive Manifesto
  • 5. event Handling data flow graph processing System Architecure zuverlässige skalierbare elastic message-driven resilient responsive http://www.reactivemanifesto.org/de
  • 6. Elastic react to load Message-Driven Services / Components Interaction Resilient react to failures Responsive react to users Reactive System goal methods concepts
  • 8.
  • 10.
  • 11. at first, dry theory…
  • 12.
  • 13. Carl Hewitt (1973), Actor Model of Computation: Scalable Robust Information Systems
  • 14.
  • 15.
  • 16.
  • 18. • Typesafe: Actor-Framework • Scala (JVM) => Java • ausgereiftes, erprobtes Framework • Akka.Net • Portierung von Akka (2013) • Aaron Stannard Roger Johansson • http://getakka.net akka.net
  • 19. Concurreny  Scalability  Fault-tolerance Simpler  Programming Model  Managed Runtime  Open Source Distribution …with a single unified
  • 21.
  • 22.
  • 23.
  • 25. PM> Install-Package Akka nuget using Akka.Actor; using (var actorSystem = ActorSystem.Create("MyActorSystem")) { // universe } nur innerhalb dieses Blocks „leben“ Aktoren var actorSystem = ActorSystem.Create("MyActorSystem")); // universe actorSystem.WhenTerminated.Wait(); // wait for termination-task actorSystem.AwaitTermination(); // deprecated oder
  • 26. // universe IActorRef myActor = actorSystem.ActorOf( Props.Create(() => new MyActor()) ); using (var actorSystem = ActorSystem.Create("MyActorSystem")) { } // talk to the actor myActor.Tell(new SomeMessage("rise up slave...")); erzeuge AktorSystem fordere spezifischen Aktor an sprich mit dem erhaltenen Aktor
  • 27. public class SomeMessage { public SomeMessage(string name) { Name = name; } public string Name { get; private set; } } public class MyActor : ReceiveActor { public MyActor() { Receive<string>(message => { Sender.Tell(message); }); Receive<SomeMessage>(message => { // react to message }); } } alle Nachrichten sind immutable Nachrichten werden prinzipiell nach ihrem Typ unterschieden * * es geht fein-granularer und abstrakter
  • 28. Receive<string>(s => Console.WriteLine("Received string: " + s)); //1 Receive<int>(i => Console.WriteLine("Received integer: " + i)); //2 IActorRef sender = Sender;
  • 29. //Receive using Funcs Receive<string>(s => { if (s.Length > 5) { Console.WriteLine("1: " + s); return true; } return false; }); Receive<string>(s => Console.WriteLine("2: " + s)); //predicates Receive<string>(s => s.Length > 5, s => Console.WriteLine("1: " + s)); //1 Receive<string>(s => s.Length > 2, s => Console.WriteLine("2: " + s)); //2 Receive<string>(s => Console.WriteLine("3: " + s)); //handler priority Receive<string>(s => s.Length > 5, s => Console.WriteLine("1: " + s)); //1 Receive<string>(s => s.Length > 2, s => Console.WriteLine("2: " + s)); //2 Receive<string>(s => Console.WriteLine("3: " + s)); //3
  • 30.
  • 31. public class MyActor : ActorBase { public MyActor() { //nothing todo } protected override bool Receive(object _message) { //handle different messages var message = _message as SomeMessage; if(message != null) { return false; } return false; } } Nachrichten werden prinzipiell nach ihrem Typ unterschieden * * es geht fein-granularer und abstrakter
  • 32. using Akka.Actor; public class MyUntypedActor : UntypedActor { protected override void OnReceive(object message) { var msg = message as Messages.InputError; if (msg != null) { // cool, its for me } else { Unhandled(message); //from ActorBase } } } • anders als beim ReceiveActor müssen nicht behandelte Nachrichten selbst als solche markiert werden
  • 33. IActorRef friend = Context.ActorOf(Props.Create(() => new MyReceiveActor())); sender.Tell(new SomeMessage("Re: " + message.Name)); IActorRef friend = ... friend.Tell(new SomeMessage("Forward: " + message.Name), sender); IActorRef friend = ... friend.Forward(new SomeMessage("Forward: " + message.Name)); forward tell + explicit sender tell
  • 34. Nicht die da, andere….
  • 35. event-driven thread Actor Behavior Mailbox State Childs Supervisor-Strategy ActorRef 1 2 34 Transport [Akka] IActorRef myActor = ... myActor.Tell(new Message("four")); • IActorRef: handle oder reference auf einen Actor • Nachrichten werden niemals direkt an einen Actor gesendet • ActorSystem fügt Metadaten (Sender, Empfänger) hinzu • ActorSystem garantiert Ankunft jeder Nachricht *
  • 36. IActorRef • Actor Namen sind optional • best practise: named actors Create Look up IActorRef myActor = actorSystem.ActorOf( Props.Create(() => new MyActor()), "myactor1" ); • adressierbar über ActorPath • Actoren bilden eine Hierarchy Parent Children Sender ActorSelection randomActor = actorSystem.ActorSelection("akka://ActorSys/user/myactor1");
  • 37. Props props1 = Props.Create(typeof(MyActor)); Props props2 = Props.Create(() => new MyActor()); Props props3 = Props.Create<MyActor>(); typeof Syntax lambda Syntax generic Syntax • einzigerWeg um Parameter zu übergeben • unsicher Context.ActorOf(props2); actorSystem.ActorOf(props2); aus einem Actor heraus: direkt im ActorSystem: -> erzeugt HierarchieVerwendung
  • 38.
  • 40. /syst em Guardians /a1 /a2 top level actor /b1 /c1 /cx /b2 /c2 /cx akka://ActorSystem/user akka://ActorSystem/user/a1 akka://ActorSystem/user/a1/b2 akka://ActorSystem/user/a1/*/cx /user /
  • 41.
  • 42. parent parent Failure SupervisionStrategy • Restart, Stop, Resume, Escalate • 2 Default-Strategien: One-For-One und All-For-One
  • 43. • erklärtes Ziel ist es Fehler einzugrenzen: • localizing the failure: fehleranfälligen Code The critical thing to know here is that *whatever action is taken on a parent propagates to its children*. If a parent is halted, all its children halt. If it is restarted, all its children restart.
  • 44. protected override SupervisorStrategy SupervisorStrategy() { // immer die gleiche Entscheidung return new OneForOneStrategy( maxNrOfRetries: 10, withinTimeRange: TimeSpan.FromSeconds(30), localOnlyDecider: exception => { Console.WriteLine("*** Supervision: Restart"); return Directive.Restart; } ); }
  • 47. public class MvcApplication : HttpApplication { protected void Application_Start() { //ASP.Net Stuff: Filters, Routes, ... //Akka init GameActorSystem.Create(); } void Application_End() { GameActorSystem.Shutdown(); } }
  • 48. public static class GameActorSystem { private static ActorSystem ActorSystem; private static IGameEventsPusher _gameEventsPusher; public static void Create() { _gameEventsPusher = new SignalRGameEventPusher(); ActorSystem = Akka.Actor.ActorSystem.Create("GameSystem"); ActorReferences.GameController = ActorSystem.ActorOf<GameControllerActor>(); ActorReferences.SignalRBridge = ActorSystem.ActorOf( Props.Create(() => new SignalRBridgeActor(_gameEventsPusher, ActorReferences.GameController)), "SignalRBridge„ ); } public static void Shutdown() { ActorSystem.Shutdown(); ActorSystem.AwaitTermination(TimeSpan.FromSeconds(1)); } public static class ActorReferences ... }
  • 49. class SignalRGameEventPusher : IGameEventsPusher { private static readonly IHubContext _gameHubContext; static SignalRGameEventPusher() //static CTOR { _gameHubContext = GlobalHost.ConnectionManager.GetHubContext<GameHub>(); } public void PlayerJoined(string playerName, int playerHealth) { _gameHubContext.Clients.All.playerJoined(playerName, playerHealth); } public void UpdatePlayerHealth(string playerName, int playerHealth) { _gameHubContext.Clients.All.updatePlayerHealth(playerName, playerHealth); } } GameHub [SignalR] ActorSystem [Akka] playerJoined updatePlayerHealth Clients Clients Clients
  • 50. public class GameHub : Hub { public void JoinGame(string playerName) { GameActorSystem .ActorReferences .SignalRBridge .Tell(new JoinGameMessage(playerName)); } public void Attack(string playerName) { GameActorSystem .ActorReferences .SignalRBridge .Tell(new AttackPlayerMessage(playerName)); } } GameHub [SignalR] join attack ActorSystem [Akka]
  • 51.

Editor's Notes

  1. shared nothing, almost maximum isolation between services no shared state (including persistence) no shared domain model or logic easy scale out & easy failover share non-functional infrastructure code network access, serialization, failover, …  ---- These changes are happening because application requirements have changed dramatically in recent years. Only a few years ago a large application had tens of servers, seconds of response time, hours of offline maintenance and gigabytes of data. Today applications are deployed on everything from mobile devices to cloud-based clusters running thousands of multi-core processors. Users expect millisecond response times and 100% uptime. Data is measured in Petabytes. Today's demands are simply not met by yesterday’s software architectures.
  2. http://www.reactivemanifesto.org/ Elastizität (im Unterschied zu Skalierbarkeit) Englisch: elasticity (in contrast to scalability) Elastizität bedeutet, dass der Durchsatz eines Systems automatisch erhöht oder vermindert werden kann, um sich an sich verändernde Lastbedingungen anzupassen. Voraussetzung hierfür ist die Skalierbarkeit des Systems, damit der Durchsatz von vermehrten Ressourcen profitieren kann. Elastizität erweitert also den Begriff der Skalierbarkeit um automatisches Ressourcenmanagement.
  3. Responsiveness = React to users / clients in timely manner (lags, „the system is down“) Avoid slow responses often means: tied up resources in calling and called system Disk IO, Out of Memory, … slow systems aren‘t usable a responsive System depends on Resilient and Elastic one
  4. Responsiveness = React to users / clients in timely manner (lags, „the system is down“) Avoid slow responses often means: tied up resources in calling and called system Disk IO, Out of Memory, … slow systems aren‘t usable a responsive System depends on Resilient and Elastic one
  5. Resilient = A resilient system react to failures it keeps processing transactions, even when there are: transient impulses persistent stresses or component failures disrupting normal processing often meant by people that say stability --- in realworld: redundancy supervisor bulk head delegation low coupled components ---  Failures are contained within each component, isolating components from each other and thereby ensuring that parts of the system can fail and recover without compromising the system as a whole. Recovery of each component is delegated to another (external) component and high-availability is ensured by replication where necessary. The client of a component is not burdened with handling its failures.  Failures are contained within each component, isolating components from each other and thereby ensuring that parts of the system can fail and recover without compromising the system as a whole. Recovery of each component is delegated to another (external) component and high-availability is ensured by replication where necessary. The client of a component is not burdened with handling its failures.
  6. Elastic = A elastic system can allocate / deallocate resources for every indivdual component (service) dynamically to match demands --- Elasticity is about resources (resources are constraint) [CPUs, Memory, VMs, …] good Idea: share N resources between M applications --- They achieve elasticity in a cost-effective way on commodity hardware and software platforms. --- Vertikale Skalierung (scale up) -> become bigger Horizontale Skalierung (scale out) -> become more --- Scalability Haiku Avoid all shared resources if you can‘t avoid it: try to batch and never block Abstraction Thread vs. Task Locking vs. Hiding & Proxying Isolation and Abstraction over Resources and State with Message-Driven Architecture
  7. Resilient = A resilient system react to failures it keeps processing transactions, even when there are: transient impulses persistent stresses or component failures disrupting normal processing often meant by people that say stability --- in realworld: redundancy supervisor bulk head delegation low coupled components ---  Failures are contained within each component, isolating components from each other and thereby ensuring that parts of the system can fail and recover without compromising the system as a whole. Recovery of each component is delegated to another (external) component and high-availability is ensured by replication where necessary. The client of a component is not burdened with handling its failures.  Failures are contained within each component, isolating components from each other and thereby ensuring that parts of the system can fail and recover without compromising the system as a whole. Recovery of each component is delegated to another (external) component and high-availability is ensured by replication where necessary. The client of a component is not burdened with handling its failures.
  8. Following Hewitt, Bishop, and Steiger's 1973 publication, Irene Greif developed an operational semantics for the Actor model as part of her doctoral research.[4] Two years later, Henry Baker and Hewitt published a set of axiomatic laws for Actor systems.[5][6] Other major milestones include William Clinger's 1981 dissertation introducing a denotational semantics based on power domains[3] and Gul Agha's 1985 dissertation which further developed a transition-based semantic model complementary to Clinger's.[7] This resulted in the full development of actor model theory. CSP: Communicating Sequential Processes / Theoretical Communicating Sequential Processes (TCSP) „Calculus of Communicating Systems“ „Algebra of Communicating Processes“ Pi-Kalkül
  9. Following Hewitt, Bishop, and Steiger's 1973 publication, Irene Greif developed an operational semantics for the Actor model as part of her doctoral research.[4] Two years later, Henry Baker and Hewitt published a set of axiomatic laws for Actor systems.[5][6] Other major milestones include William Clinger's 1981 dissertation introducing a denotational semantics based on power domains[3] and Gul Agha's 1985 dissertation which further developed a transition-based semantic model complementary to Clinger's.[7] This resulted in the full development of actor model theory. CSP: Communicating Sequential Processes / Theoretical Communicating Sequential Processes (TCSP) „Calculus of Communicating Systems“ „Algebra of Communicating Processes“ Pi-Kalkül
  10. Following Hewitt, Bishop, and Steiger's 1973 publication, Irene Greif developed an operational semantics for the Actor model as part of her doctoral research.[4] Two years later, Henry Baker and Hewitt published a set of axiomatic laws for Actor systems.[5][6] Other major milestones include William Clinger's 1981 dissertation introducing a denotational semantics based on power domains[3] and Gul Agha's 1985 dissertation which further developed a transition-based semantic model complementary to Clinger's.[7] This resulted in the full development of actor model theory. CSP: Communicating Sequential Processes / Theoretical Communicating Sequential Processes (TCSP) „Calculus of Communicating Systems“ „Algebra of Communicating Processes“ Pi-Kalkül
  11. An actor is a computational entity that, in response to a message it receives, can concurrently: send a finite number of messages to other actors; create a finite number of new actors; designate the behavior to be used for the next message it receives. There is no assumed sequence to the above actions and they could be carried out in parallel. Decoupling the sender from communications sent was a fundamental advance of the Actor model enablingasynchronous communication and control structures as patterns of passing messages.[9] Recipients of messages are identified by address, sometimes called "mailing address". Thus an actor can only communicate with actors whose addresses it has. It can obtain those from a message it receives, or if the address is for an actor it has itself created. The Actor model is characterized by inherent concurrency of computation within and among actors, dynamic creation of actors, inclusion of actor addresses in messages, and interaction only through direct asynchronousmessage passing with no restriction on message arrival order. -------- functions, coroutines, processes, numbers, lists, databases, and devices should be represented as actors
  12. An actor is a computational entity that, in response to a message it receives, can concurrently: send a finite number of messages to other actors; create a finite number of new actors; designate the behavior to be used for the next message it receives. There is no assumed sequence to the above actions and they could be carried out in parallel. Decoupling the sender from communications sent was a fundamental advance of the Actor model enablingasynchronous communication and control structures as patterns of passing messages.[9] Recipients of messages are identified by address, sometimes called "mailing address". Thus an actor can only communicate with actors whose addresses it has. It can obtain those from a message it receives, or if the address is for an actor it has itself created. The Actor model is characterized by inherent concurrency of computation within and among actors, dynamic creation of actors, inclusion of actor addresses in messages, and interaction only through direct asynchronousmessage passing with no restriction on message arrival order. -------- The actor theory requires that everything in the system, functions, coroutines, processes, numbers, lists, databases, and devices should be represented as actors, and be capable of receiving messages. This may seem at first a little dogmatic, but there are important practical benefits that arise from having a totally actor-oriented system.
  13. Never think in terms of shared state, state visibility, threads, locks, concurrent collections, thread notifications etc. Low level concurrency plumbing BECOMES SIMPLE WORKFLOW - you only think about how messages flow in the system You get high CPU utilization, low latency, high throughput and scalability - FOR FREE as part of the model Proven and superior model for detecting and recovering from errors ------ Actors are location transparent & distributable by design Scale UP and OUT for free as part of the model You get the PERFECT FABRIC for the CLOUD elastic & dynamic fault-tolerant & self-healing adaptive load-balancing, cluster rebalancing & actor migration build extremely loosely coupled and dynamic systems that can change and adapt at runtime
  14. Never think in terms of shared state, state visibility, threads, locks, concurrent collections, thread notifications etc. Low level concurrency plumbing BECOMES SIMPLE WORKFLOW - you only think about how messages flow in the system You get high CPU utilization, low latency, high throughput and scalability - FOR FREE as part of the model Proven and superior model for detecting and recovering from errors ------ Actors are location transparent & distributable by design Scale UP and OUT for free as part of the model You get the PERFECT FABRIC for the CLOUD elastic & dynamic fault-tolerant & self-healing adaptive load-balancing, cluster rebalancing & actor migration build extremely loosely coupled and dynamic systems that can change and adapt at runtime
  15. Never think in terms of shared state, state visibility, threads, locks, concurrent collections, thread notifications etc. Low level concurrency plumbing BECOMES SIMPLE WORKFLOW - you only think about how messages flow in the system You get high CPU utilization, low latency, high throughput and scalability - FOR FREE as part of the model Proven and superior model for detecting and recovering from errors ------ Actors are location transparent & distributable by design Scale UP and OUT for free as part of the model You get the PERFECT FABRIC for the CLOUD elastic & dynamic fault-tolerant & self-healing adaptive load-balancing, cluster rebalancing & actor migration build extremely loosely coupled and dynamic systems that can change and adapt at runtime
  16. Transaction processing (Online Gaming, Finance/Banking, Trading, Statistics, Betting, Social Media, Telecom) Scale up, scale out, fault-tolerance / HA Service backend (any industry, any app) Service REST, SOAP, Cometd, WebSockets etc Act as message hub / integration layer Scale up, scale out, fault-tolerance / HA Concurrency/parallelism (any app) Correct Simple to work with and understand Just add the jars to your existing JVM project (use Scala, Java, Groovy or JRuby) Simulation Master/Worker, Compute Grid, MapReduce etc. Batch processing (any industry) Camel integration to hook up with batch data sources Actors divide and conquer the batch workloads Communications Hub (Telecom, Web media, Mobile media) Scale up, scale out, fault-tolerance / HA Gaming and Betting (MOM, online gaming, betting) Scale up, scale out, fault-tolerance / HA Business Intelligence/Data Mining/general purpose crunching Scale up, scale out, fault-tolerance / HA Complex Event Stream Processing Scale up, scale out, fault-tolerance / HA
  17. NOTE: When creating Props, ActorSystem, or ActorRef you will very rarely see the new keyword. These objects must be created through the factory methods built into Akka.NET. If you're using new you might be making a mistake.
  18. NOTE: When creating Props, ActorSystem, or ActorRef you will very rarely see the new keyword. These objects must be created through the factory methods built into Akka.NET. If you're using new you might be making a mistake.
  19. NOTE: When creating Props, ActorSystem, or ActorRef you will very rarely see the new keyword. These objects must be created through the factory methods built into Akka.NET. If you're using new you might be making a mistake.
  20. With an UntypedActor, unhandled messages are not logged as unhandled unless you manually mark them as such, like so: However, in a ReceiveActor—which we cover in Unit 2—unhandled messages are automatically sent to Unhandled so the logging is done for you.
  21. Anmerkung: Messages SIND immutable ------ Messages Are Immutable Time for a fun developer buzzword that will make you sound really smart:immutability! So what’s an “immutable” object? An immutable object is an object who’s state (i.e. the contents of its memory) cannot be modified once it’s been created. If you’re a .NET developer, you’ve used the string class. Did you know that in .NETstring is an immutable object? Let me give you an example: var myStr = "Hi!".ToLowerInvariant().Replace("!", "?"); In this example, the following occurs in this order: .NET allocates a const string with the content Hi!” and then ToLowerInvariant() is called, which copies the original “Hi!” string and modifies the copy to become all lowercase and returns the modified copy (which now reads as “hi!”) Then .Replace(string,string) is called, which copies the “hi!” string returned byToLowerInvariant and modifies the copy to substitute ! with ? and returns the modified copy, with the final result reading as “hi?” Since the original string is immutable, all of these operations had to make a copy of the string before they could make their changes. Immutable messages are inherently thread-safe. No thread can modify the content of an immutable message, so a second thread receiving the original message doesn’t have to worry about a previous thread altering the state in an unpredictable way.
  22. You do talk to them, just not directly :) You have to talk to them via the intermediary of the ActorSystem. It gives you better information to work with and messaging semantics. The ActorSystem wraps all messages in anEnvelope that contains metadata about the message. This metadata is automatically unpacked and made available in the context of your actor. It allows "location transparency": this is a fancy way of saying that you don't have to worry about which process or machine your actor lives in. Keeping track of all this is the system's job. This is essential for allowing remote actors, which is how you can scale an actor system up to handle massive amounts of data (e.g. have it work on multiple machines in a cluster). More on this later.
  23. *CAUTION*: Do NOT call new MyActorClass() outside of Props and the ActorSystem to make an actor.
  24. There are two key reasons actors exist in a hierarchy: To atomize work and turn massive amounts of data into manageable chunks To contain errors and make the system resilient Since parents supervise their children, this means that every actor has a supervisor, and every actor can also BE a supervisor.
  25. / - The Root Guardian /user – Root Actor Actor path == actor position in hierarchy
  26. Here's the sequence of events when an error occurs: Unhandled exception occurs in child actor (c1), which is supervised by its parent (b1). c1 suspends operations. The system sends a Failure message from c1 to b1, with the Exception that was raised. b1 issues a directive to c1 telling it what to do. Life goes on, and the affected part of the system heals itself without burning down the whole house. The critical thing to know here is that *whatever action is taken on a parent propagates to its children*. If a parent is halted, all its children halt. If it is restarted, all its children restart.Kittens and unicorns, handing out free ice cream and coffee to be enjoyed while relaxing on a pillowy rainbow. Yay! ---- Restart the child (default): this is the common case, and the default. Stop the child: this permanently terminates the child actor. Escalate the error (and stop itself): this is the parent saying "I don't know what to do! I'm gonna stop everything and ask MY parent!" Resume processing (ignores the error): you generally won't use this. Ignore it for now.
  27. Here's the sequence of events when an error occurs: Unhandled exception occurs in child actor (c1), which is supervised by its parent (b1). c1 suspends operations. The system sends a Failure message from c1 to b1, with the Exception that was raised. b1 issues a directive to c1 telling it what to do. Life goes on, and the affected part of the system heals itself without burning down the whole house. The critical thing to know here is that *whatever action is taken on a parent propagates to its children*. If a parent is halted, all its children halt. If it is restarted, all its children restart.Kittens and unicorns, handing out free ice cream and coffee to be enjoyed while relaxing on a pillowy rainbow. Yay! ---- Restart the child (default): this is the common case, and the default. Stop the child: this permanently terminates the child actor. Escalate the error (and stop itself): this is the parent saying "I don't know what to do! I'm gonna stop everything and ask MY parent!" Resume processing (ignores the error): you generally won't use this. Ignore it for now.