SlideShare uma empresa Scribd logo
1 de 54
Baixar para ler offline
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()
@>
Actor Clustering with Docker Containers and Akka.Net in F#
Actor Clustering with Docker Containers and Akka.Net in F#
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
}
Actor Clustering with Docker Containers and Akka.Net in F#
Actor Clustering with Docker Containers and Akka.Net in F#
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

Mais conteúdo relacionado

Mais procurados

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
 

Mais procurados (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
 

Destaque

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
 

Destaque (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
 

Semelhante a 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
 
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 matterSkills Matter
 
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
 

Semelhante a 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
 
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 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
 

Último

KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostMatt Ray
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxMatsuo Lab
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Commit University
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdfPedro Manuel
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...DianaGray10
 
Things you didn't know you can use in your Salesforce
Things you didn't know you can use in your SalesforceThings you didn't know you can use in your Salesforce
Things you didn't know you can use in your SalesforceMartin Humpolec
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationIES VE
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaborationbruanjhuli
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding TeamAdam Moalla
 
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Will Schroeder
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsSeth Reyes
 
Machine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfMachine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfAijun Zhang
 
UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPathCommunity
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UbiTrack UK
 
COMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a WebsiteCOMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a Websitedgelyza
 
20200723_insight_release_plan
20200723_insight_release_plan20200723_insight_release_plan
20200723_insight_release_planJamie (Taka) Wang
 
UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8DianaGray10
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfinfogdgmi
 
Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Adtran
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureEric D. Schabell
 

Último (20)

KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCostKubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
KubeConEU24-Monitoring Kubernetes and Cloud Spend with OpenCost
 
Introduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptxIntroduction to Matsuo Laboratory (ENG).pptx
Introduction to Matsuo Laboratory (ENG).pptx
 
Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)Crea il tuo assistente AI con lo Stregatto (open source python framework)
Crea il tuo assistente AI con lo Stregatto (open source python framework)
 
Nanopower In Semiconductor Industry.pdf
Nanopower  In Semiconductor Industry.pdfNanopower  In Semiconductor Industry.pdf
Nanopower In Semiconductor Industry.pdf
 
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
Connector Corner: Extending LLM automation use cases with UiPath GenAI connec...
 
Things you didn't know you can use in your Salesforce
Things you didn't know you can use in your SalesforceThings you didn't know you can use in your Salesforce
Things you didn't know you can use in your Salesforce
 
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve DecarbonizationUsing IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
Using IESVE for Loads, Sizing and Heat Pump Modeling to Achieve Decarbonization
 
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online CollaborationCOMPUTER 10: Lesson 7 - File Storage and Online Collaboration
COMPUTER 10: Lesson 7 - File Storage and Online Collaboration
 
9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team9 Steps For Building Winning Founding Team
9 Steps For Building Winning Founding Team
 
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
Apres-Cyber - The Data Dilemma: Bridging Offensive Operations and Machine Lea...
 
Computer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and HazardsComputer 10: Lesson 10 - Online Crimes and Hazards
Computer 10: Lesson 10 - Online Crimes and Hazards
 
Machine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdfMachine Learning Model Validation (Aijun Zhang 2024).pdf
Machine Learning Model Validation (Aijun Zhang 2024).pdf
 
UiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation DevelopersUiPath Community: AI for UiPath Automation Developers
UiPath Community: AI for UiPath Automation Developers
 
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
UWB Technology for Enhanced Indoor and Outdoor Positioning in Physiological M...
 
COMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a WebsiteCOMPUTER 10 Lesson 8 - Building a Website
COMPUTER 10 Lesson 8 - Building a Website
 
20200723_insight_release_plan
20200723_insight_release_plan20200723_insight_release_plan
20200723_insight_release_plan
 
UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8UiPath Studio Web workshop series - Day 8
UiPath Studio Web workshop series - Day 8
 
Videogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdfVideogame localization & technology_ how to enhance the power of translation.pdf
Videogame localization & technology_ how to enhance the power of translation.pdf
 
Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™Meet the new FSP 3000 M-Flex800™
Meet the new FSP 3000 M-Flex800™
 
OpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability AdventureOpenShift Commons Paris - Choose Your Own Observability Adventure
OpenShift Commons Paris - Choose Your Own Observability Adventure
 

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() @>
  • 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 }
  • 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