SlideShare uma empresa Scribd logo
1 de 44
Actor Model in .NET:
Akka.NET vs Microsoft Orleans
for the curious
William Tulloch
Lead Consultant – Readify
@wtulloch
Preamble
Concurrency and distributed applications
What is the Actor Model?
The Model of Actor Model
A way of reasoning about concurrent computation
What is the Actor Model
A way of reasoning about concurrent computation
Is inherently concurrent
The Model of Actor Model
Is a conceptual model for reasoning about concurrent
computation
Is inherently concurrent
Manages concurrency through message passing
The Model of Actor Model
Is a conceptual model for reasoning about concurrent
computation
Adopts the philosophy that everything is an actor
Is inherently concurrent
Manages concurrency through message passing
What is an Actor?
Lightweight
Never shares state
Communicates through asynchronous
messages
Has a mailbox to buffer messages
Processes one message at a time
Is a single-thread object
An Actor Can not exist on its own
Microsoft Orleans
&
Akka.NET
The overview
Akka.NET
• A port of Java/Scala Akka
• Open source
• Task Parallel Library
• Reactive methodology
• Can be run within an application,
on-prem or in the cloud(?)
The overview
Orleans
• Started by Microsoft Research
• Open source
• Task Parallel Library
• Reactive methodology
• Cloud-native
Akka.NET
• A port of Java/Scala Akka
• Open source
• Task Parallel Library
• Reactive methodology
• Can be run within an application, on-
prem or in the cloud(?)
Orleans versus Akka.NET
Hosting Actors
Image from Halo Orleans at build 2104
Orleans - SiloAkka - ActorSystem
Hosting Actors
Image from Halo Orleans at build 2104
Orleans - SiloAkka - ActorSystem
Actors versus Grains
Orleans: An Actor is Grain
Grain instances always exist virtually
Orleans: An Actor is Grain
Grain instances always exist virtually
Are created on demand
Orleans: An Actor is Grain
Grain instances always exist virtually
Are created on demand
Are location transparent
Orleans: An Actor is Grain
Grain instances always exist virtually
Are created on demand
Are location transparent
Every grain must have an Id
Akka.NET: An Actor is Actor
Must be explicitly created and stopped
Akka.NET: An Actor is Actor
Must be explicitly created and stopped
Are created in the context of their parent
Akka.NET: An Actor is Actor
Must be explicitly created and stopped
Are created in the context of their parent
Exposes a set of life-cycle hooks
Akka.NET: An Actor is Actor
Must be explicitly created and stopped
Are created in the context of their parent
Exposes a set of life-cycle hooks
Are location transparent
akka.tcp://Demo@127.0.0.1:12345/user/HelloWorld/$c
Creating grains and actors
Creating a grain
Orleans – creating a grain
• In Visual Studio create two projects
• One for your grain interfaces
• One for your grain implementations
• In both projects install the NuGet package
Microsoft.Orleans.OrleansCodeGenerator.build
Create a Grain interface
public interface IHelloWorld : IGrainWithIntegerKey
{
Task Greeting(string name);
Task<string> ReturnGreeting(string name);
}
Must implement one of the
following:
• IGrainWithIntegerKey
• IGrainWithGuidKey
• IGrainWithStringKey
• IGrainWithIntegerCompoundKey
• IGrainWithGuidCompoundKey
Create an implementation of the interface
public class HelloWorldGrain : Grain, IHelloWorld
{
public Task Greeting(string name)
{
Console.WriteLine($"Hi {name} from Orleans");
return TaskDone.Done;
}
public Task<string> ReturnGreeting(string name)
{
return Task.FromResult($"Hi {name} from Orleans");
}
}
Interacting with Grains
static async Task SendMessage(User user )
{
var helloWorld = GrainClient.GrainFactory.GetGrain<IHelloWorld>(0);
var response = await helloWorld.Greeting(user);
WriteLine(response);
}
Creating an Actor
Akka.Net – creating an actor
• In Visual Studio:
• Create a new class library
• Create a console application
• Import the core Akka.NET Nuget package: Akka
Create message
public class HelloUserMessage
{
public User User { get; }
public HelloUserMessage(User user)
{
User = user;
}
}
Create an actor
public class HelloWorldActor : ReceiveActor
{
private TimeSpan _waitPeriod;
public HelloWorldActor(TimeSpan waitPeriod)
{
_waitPeriod = waitPeriod;
Receive<HelloUserMessage>(m =>
{
var user = m.User;
Thread.Sleep(_waitPeriod);
WriteLine($"Hi {user.Id} {user.FirstName} nice to meet you [on thread ");
});
Receive<DataCompleted>(m => WriteLine("Data is completed"));
}
Using the actor
var system = ActorSystem.Create("demo")
var helloWorld = system.ActorOf(Props.Create(() => new HelloWorldActor()));
helloWorld.Tell(new HelloUserMessage(new User());
await system.Terminate();
Demo Hello World
Messages and Serialisation
Messages and Serialisation
public class UserMessage
{
public string FirstName { get;}
public string LastName { get;}
public UserMessage(string firstName, string lastName)
{
FirstName = firstName;
LastName = lastName;
}
}
Messages and serialisation
Task<string> Greeting(string firstName, string lastName);
Task<Immutable<byte[]>> ProcessRequest(Immutable<byte[]> request);
Messages and Serialisation
[Immutable]
public class User
{
public string FirstName { get;}
public string LastName { get;}
}
Bits and Pieces
“let it crash” and exception handling
Persisting state
Changing behaviour
Grains for everyone
Routing in Akka.NET
Clustering in Akka.NET
Summing up
Resources
Akka.NET
Akka.NET home: http://getakka.net/
Bootcamp: https://github.com/petabridge/akka-bootcamp
Orleans
Orleans Home: http://dotnet.github.io/orleans/
Halo-Orleans: https://channel9.msdn.com/Events/Build/2014/3-641
Comparing Akka.NET and Orleans: https://github.com/akka/akka-
meta/blob/master/ComparisonWithOrleans.md

Mais conteúdo relacionado

Mais procurados

What's the time? ...and why? (Mattias Sax, Confluent) Kafka Summit SF 2019
What's the time? ...and why? (Mattias Sax, Confluent) Kafka Summit SF 2019What's the time? ...and why? (Mattias Sax, Confluent) Kafka Summit SF 2019
What's the time? ...and why? (Mattias Sax, Confluent) Kafka Summit SF 2019confluent
 
PC 와 모바일에서의 P2P 게임 구현에서의 차이점 비교
PC 와 모바일에서의 P2P 게임 구현에서의 차이점 비교PC 와 모바일에서의 P2P 게임 구현에서의 차이점 비교
PC 와 모바일에서의 P2P 게임 구현에서의 차이점 비교iFunFactory Inc.
 
WebRTC, RED and Janus @ ClueCon21
WebRTC, RED and Janus @ ClueCon21WebRTC, RED and Janus @ ClueCon21
WebRTC, RED and Janus @ ClueCon21Lorenzo Miniero
 
The Dual write problem
The Dual write problemThe Dual write problem
The Dual write problemJeppe Cramon
 
18 Months of Event Sourcing and CQRS Using Microsoft Orleans
18 Months of Event Sourcing and CQRS Using Microsoft Orleans18 Months of Event Sourcing and CQRS Using Microsoft Orleans
18 Months of Event Sourcing and CQRS Using Microsoft OrleansAndy Hoyle
 
Schema Registry 101 with Bill Bejeck | Kafka Summit London 2022
Schema Registry 101 with Bill Bejeck | Kafka Summit London 2022Schema Registry 101 with Bill Bejeck | Kafka Summit London 2022
Schema Registry 101 with Bill Bejeck | Kafka Summit London 2022HostedbyConfluent
 
コードで感じるKotlin入門
コードで感じるKotlin入門コードで感じるKotlin入門
コードで感じるKotlin入門iPride Co., Ltd.
 
Observability; a gentle introduction
Observability; a gentle introductionObservability; a gentle introduction
Observability; a gentle introductionBram Vogelaar
 
Architecting your WebRTC application for scalability, Arin Sime
Architecting your WebRTC application for scalability, Arin SimeArchitecting your WebRTC application for scalability, Arin Sime
Architecting your WebRTC application for scalability, Arin SimeAlan Quayle
 
Storage Capacity Management on Multi-tenant Kafka Cluster with Nurettin Omeroglu
Storage Capacity Management on Multi-tenant Kafka Cluster with Nurettin OmerogluStorage Capacity Management on Multi-tenant Kafka Cluster with Nurettin Omeroglu
Storage Capacity Management on Multi-tenant Kafka Cluster with Nurettin OmerogluHostedbyConfluent
 
CQRS + Event Sourcing
CQRS + Event SourcingCQRS + Event Sourcing
CQRS + Event SourcingMike Bild
 
Building Event-Driven Services with Apache Kafka
Building Event-Driven Services with Apache KafkaBuilding Event-Driven Services with Apache Kafka
Building Event-Driven Services with Apache Kafkaconfluent
 
Apache Camel K - Copenhagen
Apache Camel K - CopenhagenApache Camel K - Copenhagen
Apache Camel K - CopenhagenClaus Ibsen
 
Event Sourcing & CQRS, Kafka, Rabbit MQ
Event Sourcing & CQRS, Kafka, Rabbit MQEvent Sourcing & CQRS, Kafka, Rabbit MQ
Event Sourcing & CQRS, Kafka, Rabbit MQAraf Karsh Hamid
 

Mais procurados (20)

Golang workshop
Golang workshopGolang workshop
Golang workshop
 
What's the time? ...and why? (Mattias Sax, Confluent) Kafka Summit SF 2019
What's the time? ...and why? (Mattias Sax, Confluent) Kafka Summit SF 2019What's the time? ...and why? (Mattias Sax, Confluent) Kafka Summit SF 2019
What's the time? ...and why? (Mattias Sax, Confluent) Kafka Summit SF 2019
 
PC 와 모바일에서의 P2P 게임 구현에서의 차이점 비교
PC 와 모바일에서의 P2P 게임 구현에서의 차이점 비교PC 와 모바일에서의 P2P 게임 구현에서의 차이점 비교
PC 와 모바일에서의 P2P 게임 구현에서의 차이점 비교
 
Spring Webflux
Spring WebfluxSpring Webflux
Spring Webflux
 
WebRTC, RED and Janus @ ClueCon21
WebRTC, RED and Janus @ ClueCon21WebRTC, RED and Janus @ ClueCon21
WebRTC, RED and Janus @ ClueCon21
 
The Dual write problem
The Dual write problemThe Dual write problem
The Dual write problem
 
Jakarta EE 8 on JDK17
Jakarta EE 8 on JDK17Jakarta EE 8 on JDK17
Jakarta EE 8 on JDK17
 
18 Months of Event Sourcing and CQRS Using Microsoft Orleans
18 Months of Event Sourcing and CQRS Using Microsoft Orleans18 Months of Event Sourcing and CQRS Using Microsoft Orleans
18 Months of Event Sourcing and CQRS Using Microsoft Orleans
 
Schema Registry 101 with Bill Bejeck | Kafka Summit London 2022
Schema Registry 101 with Bill Bejeck | Kafka Summit London 2022Schema Registry 101 with Bill Bejeck | Kafka Summit London 2022
Schema Registry 101 with Bill Bejeck | Kafka Summit London 2022
 
コードで感じるKotlin入門
コードで感じるKotlin入門コードで感じるKotlin入門
コードで感じるKotlin入門
 
Observability; a gentle introduction
Observability; a gentle introductionObservability; a gentle introduction
Observability; a gentle introduction
 
Architecting your WebRTC application for scalability, Arin Sime
Architecting your WebRTC application for scalability, Arin SimeArchitecting your WebRTC application for scalability, Arin Sime
Architecting your WebRTC application for scalability, Arin Sime
 
Storage Capacity Management on Multi-tenant Kafka Cluster with Nurettin Omeroglu
Storage Capacity Management on Multi-tenant Kafka Cluster with Nurettin OmerogluStorage Capacity Management on Multi-tenant Kafka Cluster with Nurettin Omeroglu
Storage Capacity Management on Multi-tenant Kafka Cluster with Nurettin Omeroglu
 
CQRS + Event Sourcing
CQRS + Event SourcingCQRS + Event Sourcing
CQRS + Event Sourcing
 
rx-java-presentation
rx-java-presentationrx-java-presentation
rx-java-presentation
 
Docker Kubernetes Istio
Docker Kubernetes IstioDocker Kubernetes Istio
Docker Kubernetes Istio
 
Building Event-Driven Services with Apache Kafka
Building Event-Driven Services with Apache KafkaBuilding Event-Driven Services with Apache Kafka
Building Event-Driven Services with Apache Kafka
 
Apache Camel K - Copenhagen
Apache Camel K - CopenhagenApache Camel K - Copenhagen
Apache Camel K - Copenhagen
 
Event Sourcing & CQRS, Kafka, Rabbit MQ
Event Sourcing & CQRS, Kafka, Rabbit MQEvent Sourcing & CQRS, Kafka, Rabbit MQ
Event Sourcing & CQRS, Kafka, Rabbit MQ
 
Mutiny + quarkus
Mutiny + quarkusMutiny + quarkus
Mutiny + quarkus
 

Semelhante a Akka.net versus microsoft orleans

Reactive Web-Applications @ LambdaDays
Reactive Web-Applications @ LambdaDaysReactive Web-Applications @ LambdaDays
Reactive Web-Applications @ LambdaDaysManuel Bernhardt
 
Building Concurrent WebObjects applications with Scala
Building Concurrent WebObjects applications with ScalaBuilding Concurrent WebObjects applications with Scala
Building Concurrent WebObjects applications with ScalaWO Community
 
Multi-threading in the modern era: Vertx Akka and Quasar
Multi-threading in the modern era: Vertx Akka and QuasarMulti-threading in the modern era: Vertx Akka and Quasar
Multi-threading in the modern era: Vertx Akka and QuasarGal Marder
 
Akka in Action: Heiko Seeburger
Akka in Action: Heiko SeeburgerAkka in Action: Heiko Seeburger
Akka in Action: Heiko SeeburgerJAX London
 
Go Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
Go Reactive: Event-Driven, Scalable, Resilient & Responsive SystemsGo Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
Go Reactive: Event-Driven, Scalable, Resilient & Responsive SystemsJonas Bonér
 
Kotlin for Android Developers - 1
Kotlin for Android Developers - 1Kotlin for Android Developers - 1
Kotlin for Android Developers - 1Mohamed Nabil, MSc.
 
Introduction to Akka - Atlanta Java Users Group
Introduction to Akka - Atlanta Java Users GroupIntroduction to Akka - Atlanta Java Users Group
Introduction to Akka - Atlanta Java Users GroupRoy Russo
 
Projects Valhalla, Loom and GraalVM at JCon 2020
Projects Valhalla, Loom and GraalVM at JCon 2020Projects Valhalla, Loom and GraalVM at JCon 2020
Projects Valhalla, Loom and GraalVM at JCon 2020Vadym Kazulkin
 
Rethinking the debugger
Rethinking the debuggerRethinking the debugger
Rethinking the debuggerIulian Dragos
 
Introduction to Actor Model and Akka
Introduction to Actor Model and AkkaIntroduction to Actor Model and Akka
Introduction to Actor Model and AkkaYung-Lin Ho
 
Build Cloud Applications with Akka and Heroku
Build Cloud Applications with Akka and HerokuBuild Cloud Applications with Akka and Heroku
Build Cloud Applications with Akka and HerokuSalesforce Developers
 
Why scala is not my ideal language and what I can do with this
Why scala is not my ideal language and what I can do with thisWhy scala is not my ideal language and what I can do with this
Why scala is not my ideal language and what I can do with thisRuslan Shevchenko
 
Beyond design patterns phpnw14
Beyond design patterns   phpnw14Beyond design patterns   phpnw14
Beyond design patterns phpnw14Anthony Ferrara
 
Projects Valhalla, Loom and GraalVM at JUG Mainz
Projects Valhalla, Loom and GraalVM at JUG MainzProjects Valhalla, Loom and GraalVM at JUG Mainz
Projects Valhalla, Loom and GraalVM at JUG MainzVadym Kazulkin
 
Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016
Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016
Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016Codemotion
 
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in ClojurescriptProgscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in ClojurescriptJohn Stevenson
 
Software design patterns in laravel by phill sparks
Software design patterns in laravel by phill sparksSoftware design patterns in laravel by phill sparks
Software design patterns in laravel by phill sparksTheavuth NHEL
 

Semelhante a Akka.net versus microsoft orleans (20)

Reactive Web-Applications @ LambdaDays
Reactive Web-Applications @ LambdaDaysReactive Web-Applications @ LambdaDays
Reactive Web-Applications @ LambdaDays
 
Building Concurrent WebObjects applications with Scala
Building Concurrent WebObjects applications with ScalaBuilding Concurrent WebObjects applications with Scala
Building Concurrent WebObjects applications with Scala
 
Multi-threading in the modern era: Vertx Akka and Quasar
Multi-threading in the modern era: Vertx Akka and QuasarMulti-threading in the modern era: Vertx Akka and Quasar
Multi-threading in the modern era: Vertx Akka and Quasar
 
Akka in Action: Heiko Seeburger
Akka in Action: Heiko SeeburgerAkka in Action: Heiko Seeburger
Akka in Action: Heiko Seeburger
 
Go Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
Go Reactive: Event-Driven, Scalable, Resilient & Responsive SystemsGo Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
Go Reactive: Event-Driven, Scalable, Resilient & Responsive Systems
 
Kotlin for Android Developers - 1
Kotlin for Android Developers - 1Kotlin for Android Developers - 1
Kotlin for Android Developers - 1
 
Introduction to Akka - Atlanta Java Users Group
Introduction to Akka - Atlanta Java Users GroupIntroduction to Akka - Atlanta Java Users Group
Introduction to Akka - Atlanta Java Users Group
 
Scala Introduction
Scala IntroductionScala Introduction
Scala Introduction
 
Scale up your thinking
Scale up your thinkingScale up your thinking
Scale up your thinking
 
Projects Valhalla, Loom and GraalVM at JCon 2020
Projects Valhalla, Loom and GraalVM at JCon 2020Projects Valhalla, Loom and GraalVM at JCon 2020
Projects Valhalla, Loom and GraalVM at JCon 2020
 
Rethinking the debugger
Rethinking the debuggerRethinking the debugger
Rethinking the debugger
 
Introduction to Actor Model and Akka
Introduction to Actor Model and AkkaIntroduction to Actor Model and Akka
Introduction to Actor Model and Akka
 
Build Cloud Applications with Akka and Heroku
Build Cloud Applications with Akka and HerokuBuild Cloud Applications with Akka and Heroku
Build Cloud Applications with Akka and Heroku
 
Why scala is not my ideal language and what I can do with this
Why scala is not my ideal language and what I can do with thisWhy scala is not my ideal language and what I can do with this
Why scala is not my ideal language and what I can do with this
 
Ruby Under The Hood
Ruby Under The HoodRuby Under The Hood
Ruby Under The Hood
 
Beyond design patterns phpnw14
Beyond design patterns   phpnw14Beyond design patterns   phpnw14
Beyond design patterns phpnw14
 
Projects Valhalla, Loom and GraalVM at JUG Mainz
Projects Valhalla, Loom and GraalVM at JUG MainzProjects Valhalla, Loom and GraalVM at JUG Mainz
Projects Valhalla, Loom and GraalVM at JUG Mainz
 
Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016
Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016
Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016
 
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in ClojurescriptProgscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
 
Software design patterns in laravel by phill sparks
Software design patterns in laravel by phill sparksSoftware design patterns in laravel by phill sparks
Software design patterns in laravel by phill sparks
 

Último

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
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxNavinnSomaal
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr BaganFwdays
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
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
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clashcharlottematthew16
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
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
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebUiPathCommunity
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Wonjun Hwang
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr LapshynFwdays
 
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
 

Último (20)

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
 
SAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptxSAP Build Work Zone - Overview L2-L3.pptx
SAP Build Work Zone - Overview L2-L3.pptx
 
CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan"ML in Production",Oleksandr Bagan
"ML in Production",Oleksandr Bagan
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
Transcript: New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
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
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
Powerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time ClashPowerpoint exploring the locations used in television show Time Clash
Powerpoint exploring the locations used in television show Time Clash
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
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
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Dev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio WebDev Dives: Streamline document processing with UiPath Studio Web
Dev Dives: Streamline document processing with UiPath Studio Web
 
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
Bun (KitWorks Team Study 노별마루 발표 2024.4.22)
 
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
"Federated learning: out of reach no matter how close",Oleksandr Lapshyn
 
DMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special EditionDMCC Future of Trade Web3 - Special Edition
DMCC Future of Trade Web3 - Special Edition
 
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
 

Akka.net versus microsoft orleans

  • 1.
  • 2. Actor Model in .NET: Akka.NET vs Microsoft Orleans for the curious William Tulloch Lead Consultant – Readify @wtulloch
  • 4. What is the Actor Model?
  • 5. The Model of Actor Model A way of reasoning about concurrent computation
  • 6. What is the Actor Model A way of reasoning about concurrent computation Is inherently concurrent
  • 7. The Model of Actor Model Is a conceptual model for reasoning about concurrent computation Is inherently concurrent Manages concurrency through message passing
  • 8. The Model of Actor Model Is a conceptual model for reasoning about concurrent computation Adopts the philosophy that everything is an actor Is inherently concurrent Manages concurrency through message passing
  • 9. What is an Actor? Lightweight Never shares state Communicates through asynchronous messages Has a mailbox to buffer messages Processes one message at a time Is a single-thread object
  • 10. An Actor Can not exist on its own
  • 12. The overview Akka.NET • A port of Java/Scala Akka • Open source • Task Parallel Library • Reactive methodology • Can be run within an application, on-prem or in the cloud(?)
  • 13. The overview Orleans • Started by Microsoft Research • Open source • Task Parallel Library • Reactive methodology • Cloud-native Akka.NET • A port of Java/Scala Akka • Open source • Task Parallel Library • Reactive methodology • Can be run within an application, on- prem or in the cloud(?)
  • 15. Hosting Actors Image from Halo Orleans at build 2104 Orleans - SiloAkka - ActorSystem
  • 16. Hosting Actors Image from Halo Orleans at build 2104 Orleans - SiloAkka - ActorSystem
  • 18. Orleans: An Actor is Grain Grain instances always exist virtually
  • 19. Orleans: An Actor is Grain Grain instances always exist virtually Are created on demand
  • 20. Orleans: An Actor is Grain Grain instances always exist virtually Are created on demand Are location transparent
  • 21. Orleans: An Actor is Grain Grain instances always exist virtually Are created on demand Are location transparent Every grain must have an Id
  • 22. Akka.NET: An Actor is Actor Must be explicitly created and stopped
  • 23. Akka.NET: An Actor is Actor Must be explicitly created and stopped Are created in the context of their parent
  • 24. Akka.NET: An Actor is Actor Must be explicitly created and stopped Are created in the context of their parent Exposes a set of life-cycle hooks
  • 25. Akka.NET: An Actor is Actor Must be explicitly created and stopped Are created in the context of their parent Exposes a set of life-cycle hooks Are location transparent akka.tcp://Demo@127.0.0.1:12345/user/HelloWorld/$c
  • 28. Orleans – creating a grain • In Visual Studio create two projects • One for your grain interfaces • One for your grain implementations • In both projects install the NuGet package Microsoft.Orleans.OrleansCodeGenerator.build
  • 29. Create a Grain interface public interface IHelloWorld : IGrainWithIntegerKey { Task Greeting(string name); Task<string> ReturnGreeting(string name); } Must implement one of the following: • IGrainWithIntegerKey • IGrainWithGuidKey • IGrainWithStringKey • IGrainWithIntegerCompoundKey • IGrainWithGuidCompoundKey
  • 30. Create an implementation of the interface public class HelloWorldGrain : Grain, IHelloWorld { public Task Greeting(string name) { Console.WriteLine($"Hi {name} from Orleans"); return TaskDone.Done; } public Task<string> ReturnGreeting(string name) { return Task.FromResult($"Hi {name} from Orleans"); } }
  • 31. Interacting with Grains static async Task SendMessage(User user ) { var helloWorld = GrainClient.GrainFactory.GetGrain<IHelloWorld>(0); var response = await helloWorld.Greeting(user); WriteLine(response); }
  • 33. Akka.Net – creating an actor • In Visual Studio: • Create a new class library • Create a console application • Import the core Akka.NET Nuget package: Akka
  • 34. Create message public class HelloUserMessage { public User User { get; } public HelloUserMessage(User user) { User = user; } }
  • 35. Create an actor public class HelloWorldActor : ReceiveActor { private TimeSpan _waitPeriod; public HelloWorldActor(TimeSpan waitPeriod) { _waitPeriod = waitPeriod; Receive<HelloUserMessage>(m => { var user = m.User; Thread.Sleep(_waitPeriod); WriteLine($"Hi {user.Id} {user.FirstName} nice to meet you [on thread "); }); Receive<DataCompleted>(m => WriteLine("Data is completed")); }
  • 36. Using the actor var system = ActorSystem.Create("demo") var helloWorld = system.ActorOf(Props.Create(() => new HelloWorldActor())); helloWorld.Tell(new HelloUserMessage(new User()); await system.Terminate();
  • 39. Messages and Serialisation public class UserMessage { public string FirstName { get;} public string LastName { get;} public UserMessage(string firstName, string lastName) { FirstName = firstName; LastName = lastName; } }
  • 40. Messages and serialisation Task<string> Greeting(string firstName, string lastName); Task<Immutable<byte[]>> ProcessRequest(Immutable<byte[]> request);
  • 41. Messages and Serialisation [Immutable] public class User { public string FirstName { get;} public string LastName { get;} }
  • 42. Bits and Pieces “let it crash” and exception handling Persisting state Changing behaviour Grains for everyone Routing in Akka.NET Clustering in Akka.NET
  • 44. Resources Akka.NET Akka.NET home: http://getakka.net/ Bootcamp: https://github.com/petabridge/akka-bootcamp Orleans Orleans Home: http://dotnet.github.io/orleans/ Halo-Orleans: https://channel9.msdn.com/Events/Build/2014/3-641 Comparing Akka.NET and Orleans: https://github.com/akka/akka- meta/blob/master/ComparisonWithOrleans.md

Notas do Editor

  1. Why has the actor model appeared to suddenly become the flavour of the month? Because multi-threaded concurrency is hard and distributed multi-threaded concurrency is harder again. Shared state Race conditions lock and deadlocks hard to understand and maintain not easily distributed. In the .NET ecosystem the three best known frameworks that in one form or another implement the actor model are service fabric, akka.net and Microsoft Orleans. It is these last two that we are looking at today. In this talk we really only to skim the surface of either of these frame works
  2. First proposed by Hewitt, Bishop and Steiger in 1973 as a mathematical theory of computation.
  3.  Another key feature of the actor model is the concept of distribution. Given an actor is a single unit of code with a mailbox and an internal state, whether that actor running locally or on a remote node is irrelevant to the sender. As long as the message gets there what does it matter?
  4. An Actor is a primitive unit of computation <click slides> In addition to characteristics an actor Can create other actors Can send messages to other actors Can change its behaviour to determine what to do with the next message Another key feature of the actor model is the concept of distribution. Given an actor is a single unit of code with a mailbox and an internal state, whether that actor running locally or on a remote node is irrelevant to the sender. As long as the message gets there what does it matter?
  5. “One actor is no actor, they come in sys­tems, and they have to have addresses so that one actor can send mes­sages to another actor.” – Carl Hewitt
  6. Having got the preliminaries out of the way time to dig into Orleans and Akka.net And have a look at how they both compare with each other and how they have approached implementing the Actor Model.
  7. So as you can see there is at least on the surface some similarities but in many ways that is where it ends. To paraphrase from Dr. Roland Kuhn's article comparing Orleans and Akka actors; with Orleans the primary focus is to simplify distributed computing so that non-experts can write efficient, scalable and reliable distributed services. Akka on the other hand is toolkit for creating distributed systems offering full control over the domain but also exposing its inherent complexity. In other words Orleans provides a relatively low entry point into the actor model paradigm for developers from an OO background whereas Akka.net requires you rethink your approach to programing.
  8. Akka uses a supervisor hierarchy
  9. Silos are more like a commune where actors exist as independent think of it like a bucket of actors
  10. an actor is a logical unit of computation and in terms of the key characteristics that make up an actor, lightweight, single threaded, no shared state, etc. Orleans and Akka.NET are pretty much on par but after that their respective implementations are radically diverge reflecting the differences in their design philosophy.
  11. In Orleans what we have been referring to as an actor is Grain. This difference in terminology reflects the difference in how The Developers of Orleans have approached the problem. A grain is also referred to as a virtual actor as it may or not exist it any point in time. Within Orleans if a grain has been idle for a period of time it will be garbage collected to free up memory. In terms of lifecycle grains are either activated or deactivated, They can never be programmatically started or stopped.
  12. Such as: PreStart PostStop PreRestart PostRestart
  13. In Akka.NET Actors explicitly communicate via messages. And by convention should be immutable (though this is currently not enforced)
  14. In Orleans the existence of a message is not so obvious and I have to admit this bothers me a little. When a grain method is invoked, the Orleans runtime makes a deep copy of the method arguments and forms the request out of the copies. This protects against the calling code modifying the argument objects before the data is passed to the called grain. The Orleans.Concurrency.Immutable wrapper class
  15. When I first