SlideShare ist ein Scribd-Unternehmen logo
1 von 54
Downloaden Sie, um offline zu lesen
Riccardo Terrell
ACTOR CLUSTERING
WITH DOCKER CONTAINERS
AND AKKA.NET IN F#
“I have no special talents. I am only passionately curious.”
- Albert Einstein
Riccardo Terrell
HOT ACTOR CLUSTERING
WITH DOCKER CONTAINERS
AND AKKA.NET IN F#
“I have no special talents. I am only passionately curious.”
- Albert Einstein
Agenda
Actor Model - quick intro
Actor (Akka) Remoting & Clustering for distributed System
F# Code-Quotations
Remote Deploy Arbitrary Actor and dependencies… HOT!
Docker integration
Introduction - Riccardo Terrell
¨ Originally from Italy, currently - Living/working in Washington DC ~10 years
¨ +/- 19 years in professional programming
n C++/VB à Java à .Net C# à Scala à Haskell à C# & F# à ??
¨ DC F# User Group - Organizer
¨ Working @
¨ Polyglot programmer - believes in the art of finding the right tool for the job
@trikace rickyterrell.com tericcardo@gmail.com
What about you?
Scenario
let config = Configuration.parse
@"akka {
actor.provider = ""Akka.Remoter
remote.helios.tcp {
hostname = localhost
port = 9234
}
}"
let system = ActorSystem.Create("FSharp")
let echoServer =
spawn system "EchoServer" <| fun mailbox ->
actor {
let! message = mailbox.Receive()
match box message with
| :? string as msg -> printfn "Hello %s" msg
| _ -> failwith "unknown message"
}
let config = Configuration.parse
@"akka {
actor.provider = ""Akka.Remoter
remote.helios.tcp {
hostname = localhost
port = 9234
}
}"
let system = ActorSystem.Create("FSharp")
type Message =
| Input of int * string
| Path of string
let echoServer =
spawn system "EchoServer" <| fun mailbox ->
actor {
let! message = mailbox.Receive()
match box message with
| :? string as msg -> printfn "Hello %s" msg
| _ -> failwith "unknown message"
}
type Message =
| Input of int * string
| Path of string
Scenario - Clustering
let config = Configuration.parse
@"akka {
actor.provider = ""Akka.Remoter
remote.helios.tcp {
hostname = localhost
port = 9234
}
}"
let system = ActorSystem.Create("FSharp")
let echoServer =
spawn system "EchoServer" <| fun mailbox ->
actor {
let! message = mailbox.Receive()
match box message with
| :? string as msg -> printfn "Hello %s" msg
| _ -> failwith "unknown message"
}
let echoServer =
spawn system "EchoServer" <| fun mailbox ->
actor {
let! message = mailbox.Receive()
match box message with
| :? string as msg -> printfn "Hello %s" msg
| _ -> failwith "unknown message"
}
let echoServer =
spawn system "EchoServer" <| fun mailbox ->
actor {
let! message = mailbox.Receive()
match box message with
| :? string as msg -> printfn "Hello %s" msg
| _ -> failwith "unknown message"
}
let echoServer =
spawn system "EchoServer" <| fun mailbox ->
actor {
let! message = mailbox.Receive()
match box message with
| :? string as msg -> printfn "Hello %s" msg
| _ -> failwith "unknown message"
}
let echoServer =
spawn system "EchoServer" <| fun mailbox ->
actor {
let! message = mailbox.Receive()
match box message with
| :? string as msg -> printfn "Hello %s" msg
| _ -> failwith "unknown message"
}
let echoServer =
spawn system "EchoServer" <| fun mailbox ->
actor {
let! message = mailbox.Receive()
match box message with
| :? string as msg -> printfn "Hello %s" msg
| _ -> failwith "unknown message"
}
Scenario
let config = Configuration.parse
@"akka {
actor.provider = ""Akka.Remoter
remote.helios.tcp {
hostname = localhost
port = 9234
}
}"
let system = ActorSystem.Create("FSharp")
let config = Configuration.parse
@"akka {
actor.provider = ""Akka.Remoter
remote.helios.tcp {
hostname = localhost
port = 9234
}
}"
let system = ActorSystem.Create("FSharp")
X
let echoServer =
spawn system "EchoServer" <| fun mailbox ->
actor {
let! message = mailbox.Receive()
match box message with
| :? string as msg -> printfn "Hello %s" msg
| _ -> failwith "unknown message"
}
type Message =
| Input of int * string
| Path of string
let echoServer =
spawn system "EchoServer" <| fun mailbox ->
actor {
let! message = mailbox.Receive()
match box message with
| :? string as msg -> printfn "Hello %s" msg
| _ -> failwith "unknown message"
}
type Message =
| Input of int * string
| Path of string
Actor Model
What is an Actor?
¤ Share Nothing
¤ Message are passed by value
¤ Light weight processes/threads
communicating through
messaging
¤ Communication only by messages
¤ Lightweight object
¤ Processing
¤ Storage – State
¤ Running on it’s own thread.
¤ Messages are buffered in a
“mailbox”
The Solution is Immutability and Isolation
Immutability
Isolation
Akka.NET
* Concurrent
* Resilient
* Distributed
* Scalable
¨ Akka.Remote
¨ Akka.Cluster
¨ Akka.Persistence
¨ Akka.Streams
¨ Supervision
¨ Routing
Akka.NET
* Concurrent
* Resilient
* Distributed
* Scalable
¨ Akka.Remote
¨ Akka.Cluster
¨ Akka.Persistence
¨ Akka.Streams
¨ Supervision
¨ Routing
Actor – Akka.NET in C#
var system = ActorSystem.Create("fizz-buzz");
public class FizzBuzzActor : ReceiveActor {
public FizzBuzzActor() {
Receive<FizzBuzzMessage>(msg => {
// code to handle the message
});
}
}
var actor = system.ActorOf(Props.Create<FizzBuzzActor>(), "fb-actor");
actor.Tell(new FizzBuzzMessage(5));
let system = ActorSystem.Create("FSharp")
type EchoServer =
inherit Actor
override x.OnReceive (message:obj) =
match message with
| :? string as msg -> printfn "Hello %s" msg
| _ -> printfn "What should I do with this thing?”
let echoServer = system.ActorOf(Props(typedefof<EchoServer>))
echoServer.Tell 42
Actor – Akka.NET in F#
let system = System.create "System" <| Configuration.load()
let greeter =
// ActorFactory -> Name -> f(Actor<Message> -> Cont<'Message, 'return>) -> ActorRef
spawn system "Greeter-Functional"
<| fun mailbox ->
let rec loop() = actor {
let! msg = mailbox.Receive()
match msg with
| Greet(w) ->printfn "Hello %s" w
return! loop() }
loop()
greeter <! GreetMsg.Greet("AKKA.Net!!")
Actor – Akka.NET in better F#
Remoting
Remotely Deploying Actors
Deploying an actor means two things simultaneously:
¨ Creating an actor instance with specific, explicitly configured properties
¨ Getting an ActorRef to that actor
static void Main(string[] args) SERVER
{
using (var system = ActorSystem.Create("DeployTarget", ConfigurationFactory.ParseString(@"
akka {
actor.provider = ""Akka.Remote.RemoteActorRefProvider, Akka.Remote""
remote {
helios.tcp {
port = 8090
hostname = localhost
}
}
}")))
{
Console.ReadKey(); }
SERVER
public class EchoActor : ReceiveActor
{
public EchoActor()
{
Receive<Hello>(hello =>
{
Console.WriteLine("[{0}]: {1}", Sender, hello.Message);
Sender.Tell(hello);
});
}
}
using (var system = ActorSystem.Create("Deployer", ConfigurationFactory.ParseString(@” CLIENT
akka { ... CONFIG AS BEFORE ... }
remote {
helios.tcp {
port = 0
hostname = localhost
}
}
}")))
{
var remoteEcho1 = system.ActorOf(Props.Create(() => new EchoActor()), "remoteecho");
var echoActor = system.ActorOf(Props.Create(() => new HelloActor(remoteEcho1)));
echoActor.Tell(“Hello”)
Location Transparency
Akka.tcp://System@10.55.1.25:9234/actorName
Protocol Actor System Address Path
<@ Code Quotations @>
// A typed code quotation.
let sum5 : Expr<int> = <@ 2 + 3 @>
val sum5 : Quotations.Expr<int> =
Call (None, op_Addition, [Value (2), Value (3)])
<@ F# Code Quotations @>
<@ F# Code Quotations @>
let rec print expr =
match expr with
| Call(exprOpt, methodInfo, exprList) ->
match exprOpt with
| Some expr -> print expr
| None -> printf "%s" methodInfo.DeclaringType.Name
for expr in exprList.Tail do print expr
| Int32(n) ->printf "%d" n
| Value(value, typ) -> printf ”%d” value
<@ F# Code Quotations @>
let fsum42 = fun x -> x + 42
<@ F# Code Quotations @>
let fsum42 = fun x -> x + 42
let serializer:BinarySerializer = FsPickler.CreateBinarySerializer()
let sum42:byte[] = serializer.Pickle<@ fsum42 @>
<@ F# Code Quotations @>
let fsum42 = fun x -> x + 42
let serializer:BinarySerializer = FsPickler.CreateBinarySerializer()
let sum42:byte[] = serializer.Pickle<@ fsum42 @>
let sum42 = serializer.UnPickle<Quotations.Expr<int -> int>> sum42
<@ F# Code Quotations @>
let fsum42 = fun x -> x + 42
let serializer:BinarySerializer = FsPickler.CreateBinarySerializer()
let sum42:byte[] = serializer.Pickle<@ fsum42 @>
let sum42 = serializer.UnPickle<Quotations.Expr<int -> int>> sum42
let sumfun = QuotationEvaluator.Evaluate sum42
printfn "%d" (sumfun 4) // print 46
let remoter =
spawne system "remote"
fun mailbox ->
let rec loop(): Cont<int * string, unit> =
actor {
let! msg = mailbox.Receive()
match msg with
| (REQ, m) ->
printfn "Remote actor received: %A" m
mailbox.Sender() <! (RES, "ECHO " + m)
| _ -> logErrorf "Received unexpected message: %A" msg
return! loop()
}
loop()
[ SpawnOption.Deploy(remoteDeploy remoteSystemAddress) ]
<@ F# Code Quotations @>
<@ F# Code Quotations @>
let remoter =
spawne system "remote"
<@ fun mailbox ->
let rec loop(): Cont<int * string, unit> =
actor {
let! msg = mailbox.Receive()
match msg with
| (REQ, m) ->
printfn "Remote actor received: %A" m
mailbox.Sender() <! (RES, "ECHO " + m)
| _ -> logErrorf "Received unexpected message: %A" msg
return! loop()
}
loop()
[ SpawnOption.Deploy(remoteDeploy remoteSystemAddress) ]
<@ fun mailbox ->
let rec loop(): Cont<int * string, unit> =
actor {
let! msg = mailbox.Receive()
match msg with
| (REQ, m) ->
printfn "Remote actor received: %A" m
mailbox.Sender() <! (RES, "ECHO " + m)
| _ -> logErrorf "Received unexpected message: %A" msg
return! loop()
}
loop()
@>
Build Processes without Docker
Code Source
Artifacts
Build System
TOOL BOX
Docker Client
Docker
Machine
Docker
Kitmaatic
Docker
Compose
VirtualBox
Docker Images
Dockerfile
FROM mono:latest
MAINTAINER Riccardo Terrell
ENV CODEDIR /var/code
RUN mkdir –p $CODEDIR
WORKDIR $CODEDIR
RUN chmod +x $CODEDIR
&& xbuild ./ActorRemote.sln /property:Configuration=Release
EXPOSE 9234
ENTRYPOINT [“mono”, “./AkkaExamples/bin/Release/AkkaExamples.exe”]
Clustering
• Load balancing
• Fault-tolerant
• Scalability
Actor Clustering
Gossip
Joining the Actor Cluster
I want to join
Acknowledged
Joining the Actor Cluster
Clustering – Just a configuration matter
let workerSystem = System.create "cluster" <| Configuration.parse """
akka {
actor {
provider = "Akka.Cluster.ClusterActorRefProvider, Akka.Cluster"
}
}
remote {
helios.tcp {
hostname = "localhost"
port = 0
}
}
cluster {
seed-nodes = [ "akka.tcp://cluster@localhost:8091/" ]
}
}"""
Clustering – Just a configuration matter
let masterSystem = System.create "cluster" <| Configuration.parse """
akka {
actor {
provider = "Akka.Cluster.ClusterActorRefProvider, Akka.Cluster"
}
}
remote {
helios.tcp {
hostname = "localhost"
port = 8091
}
}
cluster {
seed-nodes = [ "akka.tcp://cluster@localhost:8091/" ]
}
}"""
Tabasco
Dynamically load modules
types and dependencies
between different actor systems
Scenario - Clustering
let config = Configuration.parse
@"akka {
actor.provider = ""Akka.Remoter
remote.helios.tcp {
hostname = localhost
port = 9234
}
}"
let system = ActorSystem.Create("FSharp")
let echoServer =
spawn system "EchoServer" <| fun mailbox ->
actor {
let! message = mailbox.Receive()
match box message with
| :? string as msg -> printfn "Hello %s" msg
| _ -> failwith "unknown message"
}
Scenario - Clustering
let config = Configuration.parse
@"akka {
actor.provider = ""Akka.Remoter
remote.helios.tcp {
hostname = localhost
port = 9234
}
}"
let system = ActorSystem.Create("FSharp")
Scenario - Clustering
let config = Configuration.parse
@"akka {
actor.provider = ""Akka.Remoter
remote.helios.tcp {
hostname = localhost
port = 9234
}
}"
let system = ActorSystem.Create("FSharp")
Tabasco - Dynamic Actor
type DynamicActor(receive: Receive, zero: obj) as this =
inherit UntypedActor()
let untypedContext = UntypedActor.Context :> IActorContext
let ctx = { Context = untypedContext}
let mutable currentState: obj = zero
let mutable currentReceive: Receive = receive
override this.OnReceive(msg:obj) =
match msg with
| :? ActorMessage as message ->
match message with
| GetState -> untypedContext.Sender.Tell currentState
| Stop -> untypedContext.Stop(untypedContext.Self)
| Load(newReceive) -> currentReceive <- newReceive
| message -> currentState <- currentReceive ctx
currentState message
Tabasco – Assemblies Resolver
type internal AssemblyReceiver (vm: VagabondManager, serverRef: IActorRef) =
member __.ServerRef = serverRef
interface IRemoteAssemblyReceiver with
member __.GetLoadedAssemblyInfo (ids:AssemblyId[]) = async {
let! reply = serverRef <? GetAssemblyInfo ids
return downcast reply
}
member __.PushAssemblies vas = async {
let! reply = serverRef <? LoadAssemblies (vm.CreateRawAssemblies vas)
return downcast reply
}
Docker & Akka.Net & F#
+ +
Summary
Building Distributed Systems
cross-platform with hot loads
(behaviors and dependencies)
One solution does not exist…
combining different tools and
programming models... bend
technonlogies to your need
How to reach me
github.com/DCFsharp
meetup.com/DC-fsharp/
@DCFsharp
rterrell@microsoft.com
Q & A ?
The tools we use have a profound (and devious!) influence on our thinking habits,
and, therefore, on our thinking abilities.
-- Edsger Dijkstra
How to reach me
github.com/rikace/Presentations/AkkaActorModel
meetup.com/DC-fsharp
@DCFsharp @TRikace
tericcardo@gmail.com
https://www.surveymonkey.com/r/S6PV89W

Weitere ähnliche Inhalte

Was ist angesagt?

Hello elixir (and otp)
Hello elixir (and otp)Hello elixir (and otp)
Hello elixir (and otp)Abel Muíño
 
Akka Cluster in Java - JCConf 2015
Akka Cluster in Java - JCConf 2015Akka Cluster in Java - JCConf 2015
Akka Cluster in Java - JCConf 2015Jiayun Zhou
 
Introduction to Elixir
Introduction to ElixirIntroduction to Elixir
Introduction to ElixirDiacode
 
Phoenix for Rails Devs
Phoenix for Rails DevsPhoenix for Rails Devs
Phoenix for Rails DevsDiacode
 
First glance at Akka 2.0
First glance at Akka 2.0First glance at Akka 2.0
First glance at Akka 2.0Vasil Remeniuk
 
Intro to React
Intro to ReactIntro to React
Intro to ReactTroy Miles
 
React Native Evening
React Native EveningReact Native Evening
React Native EveningTroy Miles
 
Akka persistence == event sourcing in 30 minutes
Akka persistence == event sourcing in 30 minutesAkka persistence == event sourcing in 30 minutes
Akka persistence == event sourcing in 30 minutesKonrad Malawski
 
React Native One Day
React Native One DayReact Native One Day
React Native One DayTroy Miles
 
Sane Sharding with Akka Cluster
Sane Sharding with Akka ClusterSane Sharding with Akka Cluster
Sane Sharding with Akka Clustermiciek
 
High Performance RPC with Finagle
High Performance RPC with FinagleHigh Performance RPC with Finagle
High Performance RPC with FinagleSamir Bessalah
 
Elixir Into Production
Elixir Into ProductionElixir Into Production
Elixir Into ProductionJamie Winsor
 
Node.js - Advanced Basics
Node.js - Advanced BasicsNode.js - Advanced Basics
Node.js - Advanced BasicsDoug Jones
 
Introduction to the New Asynchronous API in the .NET Driver
Introduction to the New Asynchronous API in the .NET DriverIntroduction to the New Asynchronous API in the .NET Driver
Introduction to the New Asynchronous API in the .NET DriverMongoDB
 
Migrating Legacy Rails Apps to Rails 3
Migrating Legacy Rails Apps to Rails 3Migrating Legacy Rails Apps to Rails 3
Migrating Legacy Rails Apps to Rails 3Clinton Dreisbach
 
Exploring Twitter's Finagle technology stack for microservices
Exploring Twitter's Finagle technology stack for microservicesExploring Twitter's Finagle technology stack for microservices
Exploring Twitter's Finagle technology stack for microservices💡 Tomasz Kogut
 

Was ist angesagt? (20)

Hello elixir (and otp)
Hello elixir (and otp)Hello elixir (and otp)
Hello elixir (and otp)
 
Akka Cluster in Java - JCConf 2015
Akka Cluster in Java - JCConf 2015Akka Cluster in Java - JCConf 2015
Akka Cluster in Java - JCConf 2015
 
Introduction to Elixir
Introduction to ElixirIntroduction to Elixir
Introduction to Elixir
 
Phoenix for Rails Devs
Phoenix for Rails DevsPhoenix for Rails Devs
Phoenix for Rails Devs
 
First glance at Akka 2.0
First glance at Akka 2.0First glance at Akka 2.0
First glance at Akka 2.0
 
Intro to React
Intro to ReactIntro to React
Intro to React
 
React Native Evening
React Native EveningReact Native Evening
React Native Evening
 
Akka persistence == event sourcing in 30 minutes
Akka persistence == event sourcing in 30 minutesAkka persistence == event sourcing in 30 minutes
Akka persistence == event sourcing in 30 minutes
 
Akka and futures
Akka and futuresAkka and futures
Akka and futures
 
Building a chatbot – step by step
Building a chatbot – step by stepBuilding a chatbot – step by step
Building a chatbot – step by step
 
React Native One Day
React Native One DayReact Native One Day
React Native One Day
 
Sane Sharding with Akka Cluster
Sane Sharding with Akka ClusterSane Sharding with Akka Cluster
Sane Sharding with Akka Cluster
 
Introduction to es6
Introduction to es6Introduction to es6
Introduction to es6
 
High Performance RPC with Finagle
High Performance RPC with FinagleHigh Performance RPC with Finagle
High Performance RPC with Finagle
 
Elixir Into Production
Elixir Into ProductionElixir Into Production
Elixir Into Production
 
Node.js - Advanced Basics
Node.js - Advanced BasicsNode.js - Advanced Basics
Node.js - Advanced Basics
 
Introduction to the New Asynchronous API in the .NET Driver
Introduction to the New Asynchronous API in the .NET DriverIntroduction to the New Asynchronous API in the .NET Driver
Introduction to the New Asynchronous API in the .NET Driver
 
Migrating Legacy Rails Apps to Rails 3
Migrating Legacy Rails Apps to Rails 3Migrating Legacy Rails Apps to Rails 3
Migrating Legacy Rails Apps to Rails 3
 
Exploring Twitter's Finagle technology stack for microservices
Exploring Twitter's Finagle technology stack for microservicesExploring Twitter's Finagle technology stack for microservices
Exploring Twitter's Finagle technology stack for microservices
 
Celery with python
Celery with pythonCelery with python
Celery with python
 

Andere mochten auch

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.NETRiccardo Terrell
 
CQRS Evolved - CQRS + Akka.NET
CQRS Evolved - CQRS + Akka.NETCQRS Evolved - CQRS + Akka.NET
CQRS Evolved - CQRS + Akka.NETDavid Hoerster
 
Building applications with akka.net
Building applications with akka.netBuilding applications with akka.net
Building applications with akka.netAnthony Brown
 
The New European PV Legislation: Issues and Challenges
The New European PV Legislation: Issues and ChallengesThe New European PV Legislation: Issues and Challenges
The New European PV Legislation: Issues and ChallengesSara Dunlap
 
Empirical Experiment on Navigation with Social Tags
Empirical Experiment on Navigation with Social TagsEmpirical Experiment on Navigation with Social Tags
Empirical Experiment on Navigation with Social TagsStefan Schweiger
 
Melanie Gonzalez and Manali Joshi
Melanie Gonzalez and  Manali Joshi Melanie Gonzalez and  Manali Joshi
Melanie Gonzalez and Manali Joshi youth_nex
 
Sports broadcasting
Sports broadcastingSports broadcasting
Sports broadcastingadictiv27
 
Trecho de "O livro das religiões"
Trecho de "O livro das religiões"Trecho de "O livro das religiões"
Trecho de "O livro das religiões"Fernando Pinheiro
 
Lareau_Slides
Lareau_SlidesLareau_Slides
Lareau_Slidesyouth_nex
 
Using Social Media for Sales Success
Using Social Media for Sales SuccessUsing Social Media for Sales Success
Using Social Media for Sales SuccessLeigh-Anne Lawrence
 
Circumcsion lesson six
Circumcsion   lesson sixCircumcsion   lesson six
Circumcsion lesson sixEbrahim Ismail
 
Expo challenge presentazione
Expo challenge presentazioneExpo challenge presentazione
Expo challenge presentazioneMauro Marigliano
 
Colour communication
Colour communicationColour communication
Colour communicationHarika Reddy
 

Andere mochten auch (20)

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
 
CQRS Evolved - CQRS + Akka.NET
CQRS Evolved - CQRS + Akka.NETCQRS Evolved - CQRS + Akka.NET
CQRS Evolved - CQRS + Akka.NET
 
Building applications with akka.net
Building applications with akka.netBuilding applications with akka.net
Building applications with akka.net
 
The New European PV Legislation: Issues and Challenges
The New European PV Legislation: Issues and ChallengesThe New European PV Legislation: Issues and Challenges
The New European PV Legislation: Issues and Challenges
 
Tahneek lesson 7
Tahneek   lesson 7Tahneek   lesson 7
Tahneek lesson 7
 
Lesson Four - Seerah
Lesson Four - SeerahLesson Four - Seerah
Lesson Four - Seerah
 
Connected Media Experiences
Connected Media ExperiencesConnected Media Experiences
Connected Media Experiences
 
Empirical Experiment on Navigation with Social Tags
Empirical Experiment on Navigation with Social TagsEmpirical Experiment on Navigation with Social Tags
Empirical Experiment on Navigation with Social Tags
 
Melanie Gonzalez and Manali Joshi
Melanie Gonzalez and  Manali Joshi Melanie Gonzalez and  Manali Joshi
Melanie Gonzalez and Manali Joshi
 
Sports broadcasting
Sports broadcastingSports broadcasting
Sports broadcasting
 
Trecho de "O livro das religiões"
Trecho de "O livro das religiões"Trecho de "O livro das religiões"
Trecho de "O livro das religiões"
 
Lesson Two - Seerah
Lesson Two - Seerah Lesson Two - Seerah
Lesson Two - Seerah
 
Fpvs
FpvsFpvs
Fpvs
 
Lareau_Slides
Lareau_SlidesLareau_Slides
Lareau_Slides
 
Using Social Media for Sales Success
Using Social Media for Sales SuccessUsing Social Media for Sales Success
Using Social Media for Sales Success
 
Bringithomefurniture pdf
Bringithomefurniture pdfBringithomefurniture pdf
Bringithomefurniture pdf
 
2012 Outside-In Holiday Infographic
2012 Outside-In Holiday Infographic2012 Outside-In Holiday Infographic
2012 Outside-In Holiday Infographic
 
Circumcsion lesson six
Circumcsion   lesson sixCircumcsion   lesson six
Circumcsion lesson six
 
Expo challenge presentazione
Expo challenge presentazioneExpo challenge presentazione
Expo challenge presentazione
 
Colour communication
Colour communicationColour communication
Colour communication
 

Ähnlich wie Hot Actor Clustering with Docker Containers and Akka.NET in F

Concurrent programming with Celluloid (MWRC 2012)
Concurrent programming with Celluloid (MWRC 2012)Concurrent programming with Celluloid (MWRC 2012)
Concurrent programming with Celluloid (MWRC 2012)tarcieri
 
Reactive Programming in .Net - actorbased computing with Akka.Net
Reactive Programming in .Net - actorbased computing with Akka.NetReactive Programming in .Net - actorbased computing with Akka.Net
Reactive Programming in .Net - actorbased computing with Akka.NetSören Stelzer
 
Fresh from the Oven (04.2015): Experimental Akka Typed and Akka Streams
Fresh from the Oven (04.2015): Experimental Akka Typed and Akka StreamsFresh from the Oven (04.2015): Experimental Akka Typed and Akka Streams
Fresh from the Oven (04.2015): Experimental Akka Typed and Akka StreamsKonrad Malawski
 
Kotlin boost yourproductivity
Kotlin boost yourproductivityKotlin boost yourproductivity
Kotlin boost yourproductivitynklmish
 
Asynchronous Orchestration DSL on squbs
Asynchronous Orchestration DSL on squbsAsynchronous Orchestration DSL on squbs
Asynchronous Orchestration DSL on squbsAnil Gursel
 
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 meetupHenrik Engström
 
Akka lsug skills matter
Akka lsug skills matterAkka lsug skills matter
Akka lsug skills matterSkills Matter
 
Scaling Web Apps with Akka
Scaling Web Apps with AkkaScaling Web Apps with Akka
Scaling Web Apps with AkkaMaciej Matyjas
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)Pavlo Baron
 
Concurrency on the JVM
Concurrency on the JVMConcurrency on the JVM
Concurrency on the JVMVaclav Pech
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfpragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfHiroshi Ono
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfpragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfHiroshi Ono
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfpragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfHiroshi Ono
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfpragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfHiroshi Ono
 
Scaladroids: Developing Android Apps with Scala
Scaladroids: Developing Android Apps with ScalaScaladroids: Developing Android Apps with Scala
Scaladroids: Developing Android Apps with ScalaOstap Andrusiv
 

Ähnlich wie Hot Actor Clustering with Docker Containers and Akka.NET in F (20)

Concurrent programming with Celluloid (MWRC 2012)
Concurrent programming with Celluloid (MWRC 2012)Concurrent programming with Celluloid (MWRC 2012)
Concurrent programming with Celluloid (MWRC 2012)
 
Reactive Programming in .Net - actorbased computing with Akka.Net
Reactive Programming in .Net - actorbased computing with Akka.NetReactive Programming in .Net - actorbased computing with Akka.Net
Reactive Programming in .Net - actorbased computing with Akka.Net
 
Unfiltered Unveiled
Unfiltered UnveiledUnfiltered Unveiled
Unfiltered Unveiled
 
Fresh from the Oven (04.2015): Experimental Akka Typed and Akka Streams
Fresh from the Oven (04.2015): Experimental Akka Typed and Akka StreamsFresh from the Oven (04.2015): Experimental Akka Typed and Akka Streams
Fresh from the Oven (04.2015): Experimental Akka Typed and Akka Streams
 
Kotlin boost yourproductivity
Kotlin boost yourproductivityKotlin boost yourproductivity
Kotlin boost yourproductivity
 
Asynchronous Orchestration DSL on squbs
Asynchronous Orchestration DSL on squbsAsynchronous Orchestration DSL on squbs
Asynchronous Orchestration DSL on squbs
 
Akka 2.0 Reloaded
Akka 2.0 ReloadedAkka 2.0 Reloaded
Akka 2.0 Reloaded
 
Akka knolx
Akka knolxAkka knolx
Akka knolx
 
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
 
Akka lsug skills matter
Akka lsug skills matterAkka lsug skills matter
Akka lsug skills matter
 
Scaling Web Apps with Akka
Scaling Web Apps with AkkaScaling Web Apps with Akka
Scaling Web Apps with Akka
 
Akka http 2
Akka http 2Akka http 2
Akka http 2
 
What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)What can be done with Java, but should better be done with Erlang (@pavlobaron)
What can be done with Java, but should better be done with Erlang (@pavlobaron)
 
Concurrency on the JVM
Concurrency on the JVMConcurrency on the JVM
Concurrency on the JVM
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfpragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfpragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfpragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
 
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdfpragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
pragmaticrealworldscalajfokus2009-1233251076441384-2.pdf
 
Scaladroids: Developing Android Apps with Scala
Scaladroids: Developing Android Apps with ScalaScaladroids: Developing Android Apps with Scala
Scaladroids: Developing Android Apps with Scala
 
Introduction to asyncio
Introduction to asyncioIntroduction to asyncio
Introduction to asyncio
 

Kürzlich hochgeladen

DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningLars Bell
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfAddepto
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostZilliz
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteDianaGray10
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024Lorenzo Miniero
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brandgvaughan
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DaySri Ambati
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLScyllaDB
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyAlfredo García Lavilla
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 3652toLead Limited
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 

Kürzlich hochgeladen (20)

DSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine TuningDSPy a system for AI to Write Prompts and Do Fine Tuning
DSPy a system for AI to Write Prompts and Do Fine Tuning
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Gen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdfGen AI in Business - Global Trends Report 2024.pdf
Gen AI in Business - Global Trends Report 2024.pdf
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage CostLeverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
Leverage Zilliz Serverless - Up to 50X Saving for Your Vector Storage Cost
 
Take control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test SuiteTake control of your SAP testing with UiPath Test Suite
Take control of your SAP testing with UiPath Test Suite
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024SIP trunking in Janus @ Kamailio World 2024
SIP trunking in Janus @ Kamailio World 2024
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
WordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your BrandWordPress Websites for Engineers: Elevate Your Brand
WordPress Websites for Engineers: Elevate Your Brand
 
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo DayH2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
H2O.ai CEO/Founder: Sri Ambati Keynote at Wells Fargo Day
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Developer Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQLDeveloper Data Modeling Mistakes: From Postgres to NoSQL
Developer Data Modeling Mistakes: From Postgres to NoSQL
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Commit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easyCommit 2024 - Secret Management made easy
Commit 2024 - Secret Management made easy
 
Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365Ensuring Technical Readiness For Copilot in Microsoft 365
Ensuring Technical Readiness For Copilot in Microsoft 365
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 

Hot Actor Clustering with Docker Containers and Akka.NET in F

  • 1. Riccardo Terrell ACTOR CLUSTERING WITH DOCKER CONTAINERS AND AKKA.NET IN F# “I have no special talents. I am only passionately curious.” - Albert Einstein
  • 2. Riccardo Terrell HOT ACTOR CLUSTERING WITH DOCKER CONTAINERS AND AKKA.NET IN F# “I have no special talents. I am only passionately curious.” - Albert Einstein
  • 3. Agenda Actor Model - quick intro Actor (Akka) Remoting & Clustering for distributed System F# Code-Quotations Remote Deploy Arbitrary Actor and dependencies… HOT! Docker integration
  • 4. Introduction - Riccardo Terrell ¨ Originally from Italy, currently - Living/working in Washington DC ~10 years ¨ +/- 19 years in professional programming n C++/VB à Java à .Net C# à Scala à Haskell à C# & F# à ?? ¨ DC F# User Group - Organizer ¨ Working @ ¨ Polyglot programmer - believes in the art of finding the right tool for the job @trikace rickyterrell.com tericcardo@gmail.com
  • 6. Scenario let config = Configuration.parse @"akka { actor.provider = ""Akka.Remoter remote.helios.tcp { hostname = localhost port = 9234 } }" let system = ActorSystem.Create("FSharp") let echoServer = spawn system "EchoServer" <| fun mailbox -> actor { let! message = mailbox.Receive() match box message with | :? string as msg -> printfn "Hello %s" msg | _ -> failwith "unknown message" } let config = Configuration.parse @"akka { actor.provider = ""Akka.Remoter remote.helios.tcp { hostname = localhost port = 9234 } }" let system = ActorSystem.Create("FSharp") type Message = | Input of int * string | Path of string let echoServer = spawn system "EchoServer" <| fun mailbox -> actor { let! message = mailbox.Receive() match box message with | :? string as msg -> printfn "Hello %s" msg | _ -> failwith "unknown message" } type Message = | Input of int * string | Path of string
  • 7. Scenario - Clustering let config = Configuration.parse @"akka { actor.provider = ""Akka.Remoter remote.helios.tcp { hostname = localhost port = 9234 } }" let system = ActorSystem.Create("FSharp") let echoServer = spawn system "EchoServer" <| fun mailbox -> actor { let! message = mailbox.Receive() match box message with | :? string as msg -> printfn "Hello %s" msg | _ -> failwith "unknown message" } let echoServer = spawn system "EchoServer" <| fun mailbox -> actor { let! message = mailbox.Receive() match box message with | :? string as msg -> printfn "Hello %s" msg | _ -> failwith "unknown message" } let echoServer = spawn system "EchoServer" <| fun mailbox -> actor { let! message = mailbox.Receive() match box message with | :? string as msg -> printfn "Hello %s" msg | _ -> failwith "unknown message" } let echoServer = spawn system "EchoServer" <| fun mailbox -> actor { let! message = mailbox.Receive() match box message with | :? string as msg -> printfn "Hello %s" msg | _ -> failwith "unknown message" } let echoServer = spawn system "EchoServer" <| fun mailbox -> actor { let! message = mailbox.Receive() match box message with | :? string as msg -> printfn "Hello %s" msg | _ -> failwith "unknown message" } let echoServer = spawn system "EchoServer" <| fun mailbox -> actor { let! message = mailbox.Receive() match box message with | :? string as msg -> printfn "Hello %s" msg | _ -> failwith "unknown message" }
  • 8. Scenario let config = Configuration.parse @"akka { actor.provider = ""Akka.Remoter remote.helios.tcp { hostname = localhost port = 9234 } }" let system = ActorSystem.Create("FSharp") let config = Configuration.parse @"akka { actor.provider = ""Akka.Remoter remote.helios.tcp { hostname = localhost port = 9234 } }" let system = ActorSystem.Create("FSharp") X let echoServer = spawn system "EchoServer" <| fun mailbox -> actor { let! message = mailbox.Receive() match box message with | :? string as msg -> printfn "Hello %s" msg | _ -> failwith "unknown message" } type Message = | Input of int * string | Path of string let echoServer = spawn system "EchoServer" <| fun mailbox -> actor { let! message = mailbox.Receive() match box message with | :? string as msg -> printfn "Hello %s" msg | _ -> failwith "unknown message" } type Message = | Input of int * string | Path of string
  • 10. What is an Actor? ¤ Share Nothing ¤ Message are passed by value ¤ Light weight processes/threads communicating through messaging ¤ Communication only by messages ¤ Lightweight object ¤ Processing ¤ Storage – State ¤ Running on it’s own thread. ¤ Messages are buffered in a “mailbox”
  • 11. The Solution is Immutability and Isolation Immutability Isolation
  • 12. Akka.NET * Concurrent * Resilient * Distributed * Scalable ¨ Akka.Remote ¨ Akka.Cluster ¨ Akka.Persistence ¨ Akka.Streams ¨ Supervision ¨ Routing
  • 13. Akka.NET * Concurrent * Resilient * Distributed * Scalable ¨ Akka.Remote ¨ Akka.Cluster ¨ Akka.Persistence ¨ Akka.Streams ¨ Supervision ¨ Routing
  • 14. Actor – Akka.NET in C# var system = ActorSystem.Create("fizz-buzz"); public class FizzBuzzActor : ReceiveActor { public FizzBuzzActor() { Receive<FizzBuzzMessage>(msg => { // code to handle the message }); } } var actor = system.ActorOf(Props.Create<FizzBuzzActor>(), "fb-actor"); actor.Tell(new FizzBuzzMessage(5));
  • 15. let system = ActorSystem.Create("FSharp") type EchoServer = inherit Actor override x.OnReceive (message:obj) = match message with | :? string as msg -> printfn "Hello %s" msg | _ -> printfn "What should I do with this thing?” let echoServer = system.ActorOf(Props(typedefof<EchoServer>)) echoServer.Tell 42 Actor – Akka.NET in F#
  • 16. let system = System.create "System" <| Configuration.load() let greeter = // ActorFactory -> Name -> f(Actor<Message> -> Cont<'Message, 'return>) -> ActorRef spawn system "Greeter-Functional" <| fun mailbox -> let rec loop() = actor { let! msg = mailbox.Receive() match msg with | Greet(w) ->printfn "Hello %s" w return! loop() } loop() greeter <! GreetMsg.Greet("AKKA.Net!!") Actor – Akka.NET in better F#
  • 18. Remotely Deploying Actors Deploying an actor means two things simultaneously: ¨ Creating an actor instance with specific, explicitly configured properties ¨ Getting an ActorRef to that actor static void Main(string[] args) SERVER { using (var system = ActorSystem.Create("DeployTarget", ConfigurationFactory.ParseString(@" akka { actor.provider = ""Akka.Remote.RemoteActorRefProvider, Akka.Remote"" remote { helios.tcp { port = 8090 hostname = localhost } } }"))) { Console.ReadKey(); } SERVER public class EchoActor : ReceiveActor { public EchoActor() { Receive<Hello>(hello => { Console.WriteLine("[{0}]: {1}", Sender, hello.Message); Sender.Tell(hello); }); } } using (var system = ActorSystem.Create("Deployer", ConfigurationFactory.ParseString(@” CLIENT akka { ... CONFIG AS BEFORE ... } remote { helios.tcp { port = 0 hostname = localhost } } }"))) { var remoteEcho1 = system.ActorOf(Props.Create(() => new EchoActor()), "remoteecho"); var echoActor = system.ActorOf(Props.Create(() => new HelloActor(remoteEcho1))); echoActor.Tell(“Hello”)
  • 21. // A typed code quotation. let sum5 : Expr<int> = <@ 2 + 3 @> val sum5 : Quotations.Expr<int> = Call (None, op_Addition, [Value (2), Value (3)]) <@ F# Code Quotations @>
  • 22. <@ F# Code Quotations @> let rec print expr = match expr with | Call(exprOpt, methodInfo, exprList) -> match exprOpt with | Some expr -> print expr | None -> printf "%s" methodInfo.DeclaringType.Name for expr in exprList.Tail do print expr | Int32(n) ->printf "%d" n | Value(value, typ) -> printf ”%d” value
  • 23. <@ F# Code Quotations @> let fsum42 = fun x -> x + 42
  • 24. <@ F# Code Quotations @> let fsum42 = fun x -> x + 42 let serializer:BinarySerializer = FsPickler.CreateBinarySerializer() let sum42:byte[] = serializer.Pickle<@ fsum42 @>
  • 25. <@ F# Code Quotations @> let fsum42 = fun x -> x + 42 let serializer:BinarySerializer = FsPickler.CreateBinarySerializer() let sum42:byte[] = serializer.Pickle<@ fsum42 @> let sum42 = serializer.UnPickle<Quotations.Expr<int -> int>> sum42
  • 26. <@ F# Code Quotations @> let fsum42 = fun x -> x + 42 let serializer:BinarySerializer = FsPickler.CreateBinarySerializer() let sum42:byte[] = serializer.Pickle<@ fsum42 @> let sum42 = serializer.UnPickle<Quotations.Expr<int -> int>> sum42 let sumfun = QuotationEvaluator.Evaluate sum42 printfn "%d" (sumfun 4) // print 46
  • 27. let remoter = spawne system "remote" fun mailbox -> let rec loop(): Cont<int * string, unit> = actor { let! msg = mailbox.Receive() match msg with | (REQ, m) -> printfn "Remote actor received: %A" m mailbox.Sender() <! (RES, "ECHO " + m) | _ -> logErrorf "Received unexpected message: %A" msg return! loop() } loop() [ SpawnOption.Deploy(remoteDeploy remoteSystemAddress) ] <@ F# Code Quotations @>
  • 28. <@ F# Code Quotations @> let remoter = spawne system "remote" <@ fun mailbox -> let rec loop(): Cont<int * string, unit> = actor { let! msg = mailbox.Receive() match msg with | (REQ, m) -> printfn "Remote actor received: %A" m mailbox.Sender() <! (RES, "ECHO " + m) | _ -> logErrorf "Received unexpected message: %A" msg return! loop() } loop() [ SpawnOption.Deploy(remoteDeploy remoteSystemAddress) ] <@ fun mailbox -> let rec loop(): Cont<int * string, unit> = actor { let! msg = mailbox.Receive() match msg with | (REQ, m) -> printfn "Remote actor received: %A" m mailbox.Sender() <! (RES, "ECHO " + m) | _ -> logErrorf "Received unexpected message: %A" msg return! loop() } loop() @>
  • 29.
  • 30.
  • 31. Build Processes without Docker Code Source Artifacts Build System
  • 34. Dockerfile FROM mono:latest MAINTAINER Riccardo Terrell ENV CODEDIR /var/code RUN mkdir –p $CODEDIR WORKDIR $CODEDIR RUN chmod +x $CODEDIR && xbuild ./ActorRemote.sln /property:Configuration=Release EXPOSE 9234 ENTRYPOINT [“mono”, “./AkkaExamples/bin/Release/AkkaExamples.exe”]
  • 35. Clustering • Load balancing • Fault-tolerant • Scalability
  • 38. Joining the Actor Cluster I want to join Acknowledged
  • 39. Joining the Actor Cluster
  • 40. Clustering – Just a configuration matter let workerSystem = System.create "cluster" <| Configuration.parse """ akka { actor { provider = "Akka.Cluster.ClusterActorRefProvider, Akka.Cluster" } } remote { helios.tcp { hostname = "localhost" port = 0 } } cluster { seed-nodes = [ "akka.tcp://cluster@localhost:8091/" ] } }"""
  • 41. Clustering – Just a configuration matter let masterSystem = System.create "cluster" <| Configuration.parse """ akka { actor { provider = "Akka.Cluster.ClusterActorRefProvider, Akka.Cluster" } } remote { helios.tcp { hostname = "localhost" port = 8091 } } cluster { seed-nodes = [ "akka.tcp://cluster@localhost:8091/" ] } }"""
  • 42. Tabasco Dynamically load modules types and dependencies between different actor systems
  • 43. Scenario - Clustering let config = Configuration.parse @"akka { actor.provider = ""Akka.Remoter remote.helios.tcp { hostname = localhost port = 9234 } }" let system = ActorSystem.Create("FSharp") let echoServer = spawn system "EchoServer" <| fun mailbox -> actor { let! message = mailbox.Receive() match box message with | :? string as msg -> printfn "Hello %s" msg | _ -> failwith "unknown message" }
  • 44. Scenario - Clustering let config = Configuration.parse @"akka { actor.provider = ""Akka.Remoter remote.helios.tcp { hostname = localhost port = 9234 } }" let system = ActorSystem.Create("FSharp")
  • 45. Scenario - Clustering let config = Configuration.parse @"akka { actor.provider = ""Akka.Remoter remote.helios.tcp { hostname = localhost port = 9234 } }" let system = ActorSystem.Create("FSharp")
  • 46. Tabasco - Dynamic Actor type DynamicActor(receive: Receive, zero: obj) as this = inherit UntypedActor() let untypedContext = UntypedActor.Context :> IActorContext let ctx = { Context = untypedContext} let mutable currentState: obj = zero let mutable currentReceive: Receive = receive override this.OnReceive(msg:obj) = match msg with | :? ActorMessage as message -> match message with | GetState -> untypedContext.Sender.Tell currentState | Stop -> untypedContext.Stop(untypedContext.Self) | Load(newReceive) -> currentReceive <- newReceive | message -> currentState <- currentReceive ctx currentState message
  • 47. Tabasco – Assemblies Resolver type internal AssemblyReceiver (vm: VagabondManager, serverRef: IActorRef) = member __.ServerRef = serverRef interface IRemoteAssemblyReceiver with member __.GetLoadedAssemblyInfo (ids:AssemblyId[]) = async { let! reply = serverRef <? GetAssemblyInfo ids return downcast reply } member __.PushAssemblies vas = async { let! reply = serverRef <? LoadAssemblies (vm.CreateRawAssemblies vas) return downcast reply }
  • 48.
  • 49.
  • 50. Docker & Akka.Net & F# + +
  • 51. Summary Building Distributed Systems cross-platform with hot loads (behaviors and dependencies) One solution does not exist… combining different tools and programming models... bend technonlogies to your need
  • 52. How to reach me github.com/DCFsharp meetup.com/DC-fsharp/ @DCFsharp rterrell@microsoft.com
  • 53. Q & A ? The tools we use have a profound (and devious!) influence on our thinking habits, and, therefore, on our thinking abilities. -- Edsger Dijkstra
  • 54. How to reach me github.com/rikace/Presentations/AkkaActorModel meetup.com/DC-fsharp @DCFsharp @TRikace tericcardo@gmail.com https://www.surveymonkey.com/r/S6PV89W