Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

From Zero to the Actor Model (With Akka.Net) - CodeMash2017 - Tamir Dresher

651 views

Published on

These are the slides from my talk at the CodeMash 2017 conferenece: http://www.codemash.org/session/creating-a-responsive-application-using-reactive-extensions/

Code examples are located here: https://github.com/tamirdresher/FromZeroToTheActorModel

Published in: Software
  • Be the first to comment

From Zero to the Actor Model (With Akka.Net) - CodeMash2017 - Tamir Dresher

  1. 1. 1 Tamir Dresher (@tamir_dresher) Senior Software Architect J From Zero to the Actor Model 1
  2. 2. 2 • Author of Rx.NET in Action (manning publications) • Software architect, consultant and instructor • Software Engineering Lecturer @ Ruppin Academic Center @tamir_dresher tamirdr@codevalue.net http://www.TamirDresher.com. About Me
  3. 3. Software Architecture is like Pasta 3By @benorama
  4. 4. Agenda 1. Actor Model 2. Semiconductors 3. Metrology Target Designer (MTD) by KLA-Tencor 4. Rearchitecting to Actor Model with Akka.NET 4
  5. 5. The Actor Model (Hewitt et al. 1973) 5 Alice Mailbox Bob Sally Mailbox Mailbox “the Actor model retained more of what I thought were the good features of the object idea.” Alan Kay Object Orientation pioneer and Smalltalk co-designer Alice Parent Bob Parent Sally Parent
  6. 6. The future platform (Juval Löwy) 6
  7. 7. Actors in Akka.NET public class CoordinatorActor : ReceiveActor { public CoordinatorActor() { Receive<StartSimulation>(start => { //Initiate a new simulation }); } } public class StartSimulation { public Guid ProjectId { get; set; } } 7
  8. 8. Demo Echo Actor 8
  9. 9. Location Transparency (kind of…) Actors live inside an ActorSystem Each Actor has a unique address Local: akka://ActorSystem-A/user/A2 Remote: akka.tcp://ActorSystem-C@Machine-B:5678/user/C1 Machine A Machine B ActorSystem A A1 A2 ActorSystem B B1 B2 ActorSystem C C1 9
  10. 10. Actor Model  Messaging  Decoupling Message passing yields decoupling Interesting messaging patterns are now available Alice Sally Bob Forwarding Alice Sally Bob Multiple Responses 10
  11. 11. MTD Case Study Metrology Target Design 11
  12. 12. KLA-Tencor Corporation is a leading supplier of process control and yield management solutions for the semiconductor and related microelectronics industries 12
  13. 13. How chip is born UV Radiation 13
  14. 14. Meaning of Overlay 14
  15. 15. Metrology Target Design (MTD) 15
  16. 16. MTD Original Architecture Technology B Services Technology A ServicesUI Clients Stack composer Material manager Simulation setup DOE generator Geometry Materials Simulation Results HTTP requests Notification hubSubscribe  Notify Notify Distribution Service Cluster Outgoing queue per simulation Incoming queue per simulation Simulation Coordinator Technology A Simulator Technology B Simulator otify 16
  17. 17. MTD Challenges Long simulations PauseResumeStop lifecycle Simulation failures Extendibility New Technologies Configurable simulation tasks Scalability 17
  18. 18. Actor Based Architecture - Hierarchy /user Simulation Coordinator Simulation Queue Simulation Notifier Technology A Coordinator Technology A Simulation Sub Simulation 1 Sub Simulation 2 Sub Simulation 3 Technology B Coordinator Technology B Simulation Sub Simulation 1 Sub Simulation 2 Sub Simulation 3 18
  19. 19. Actor Based Architecture – Messages Flow WebApi Controller Simulation Coordinator 1.Start Simulation Queue 2.AddNew Simulation Notifier 4. SimulationStatusChanged 3.SimulationStatusChanged 5.SimulationStatusChanged [Technology] Coordinator [Technology] Simualtion (id=xxxx) 11.MarkStarted 12. SimulationStatusChanged SignalR 19
  20. 20. Statefulness and Behavior switching Stateful is no longer a dirty word (kind of…) The less calls you have for the persistence store the better the performance will be Durability is a must (state-awareness) State goes hand-in-hand with supported behavior Actors have the power to switch their behaviors at any point in time. the actor becomes busy or the actor becomes connected. Which messages to Receive, Deny, Postpone (Stashing) State machine 20
  21. 21. <configuration> <configSections> <section name="akka" type="Akka.Configuration.Hocon.AkkaConfigurationSection, Akka"/> </configSections> <akka> <hocon> <![CDATA[ akka { actor { provider = "Akka.Remote.RemoteActorRefProvider, Akka.Remote" } remote { helios.tcp { port = 8098 hostname = localhost } } [[> </hocon> </akka> </configuration> Remoting and Location Transparancy ActorSelection selection = sys.ActorSelection("akka.tcp://ActorSystem-C@Machine-B:5678/user/C1"); 21
  22. 22. Routers http://getakka.net/docs/working-with-actors/Routers ConsistentHashing akka.actor.deployment { /workers { router = round-robin-group routees.paths = ["/user/workers/w1", "/user/workers/w2", "/user/workers/w3"] } } Broadcast RoundRobin var props = Props.Create<Worker>().WithRouter(FromConfig.Instance); IActroRef actor = system.ActorOf(props, "workers"); 22
  23. 23. Routing to Remote Actors 23 <hocon> <![CDATA[ akka { actor { provider = "Akka.Remote.RemoteActorRefProvider, Akka.Remote" deployment { /Technologies { router = broadcast-group routees.paths = ["akka.tcp://TechnologyA@localhost:8091/user/coordinator"] } } } : : } ]]> </hocon> IActroRef technologies = _system.ActorOf(Props.Empty.WithRouter(FromConfig.Instance), "Technologies");
  24. 24. Final thoughts Testing – easier sometimes, harder sometimes Dependency injection – injecting ActorRefsActorSelections is not intuitive Runtime contract vs. compile-time contract Your messages are the contract Messages versioning should be considered up-front 24
  25. 25. Summary 1. Actor Model 2. Semi conductor 3. Metrology Target Designer (MTD) by KLA-Tencor 4. Rearchitecting to Actor Model with Akka.NET 25
  26. 26. https://www.manning.com/books/ rx-dot-net-in-action www.manning.com/books/ reactive-applications-with-akka-net Discount code: ctwcodemash17 Thank You Tamir Dresher (@tamir_dresher) http://getakka.net/ https://github.com/akkadotnet/akka.net 26

×