Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016
-
Upload
codemotion -
Category
Technology
-
view
205 -
download
3
Transcript of Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016
![Page 1: Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016](https://reader036.fdocuments.net/reader036/viewer/2022081323/58f27c3a1a28abbd798b4635/html5/thumbnails/1.jpg)
Un actor (model) per amicoAlessandro Melchiori
![Page 2: Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016](https://reader036.fdocuments.net/reader036/viewer/2022081323/58f27c3a1a28abbd798b4635/html5/thumbnails/2.jpg)
TheSpeaker.AboutMe();
• Alessandro Melchiori
• @amelchiori
• http://melkio.codiceplastico.com
• http://github.com/melkio
![Page 3: Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016](https://reader036.fdocuments.net/reader036/viewer/2022081323/58f27c3a1a28abbd798b4635/html5/thumbnails/3.jpg)
![Page 4: Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016](https://reader036.fdocuments.net/reader036/viewer/2022081323/58f27c3a1a28abbd798b4635/html5/thumbnails/4.jpg)
concurrency + shared state = easy
![Page 5: Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016](https://reader036.fdocuments.net/reader036/viewer/2022081323/58f27c3a1a28abbd798b4635/html5/thumbnails/5.jpg)
![Page 6: Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016](https://reader036.fdocuments.net/reader036/viewer/2022081323/58f27c3a1a28abbd798b4635/html5/thumbnails/6.jpg)
Shared state and concurrency
• Synchronizing shared state
• Coordinating work among threads
• Use synchronization mechanisms
• Debugging..WTF?
• ...
![Page 7: Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016](https://reader036.fdocuments.net/reader036/viewer/2022081323/58f27c3a1a28abbd798b4635/html5/thumbnails/7.jpg)
Actor model
The actor model in computer science is a mathematical model of concurrent computation that treats "actors" as the universal primitives of concurrent computation: in response to a message that it receives, an actor can make local decisions, create more actors, send more messages, and determine how to respond to the next message received
https://en.wikipedia.org/wiki/Actor_model
![Page 8: Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016](https://reader036.fdocuments.net/reader036/viewer/2022081323/58f27c3a1a28abbd798b4635/html5/thumbnails/8.jpg)
Actor model
The actor model in computer science is a mathematical model of concurrent computation that treats "actors" as the universal primitives of concurrent computation: in response to a message that it receives, an actor can make local decisions, create more actors, send more messages, and determine how to respond to the next message received
https://en.wikipedia.org/wiki/Actor_model
![Page 9: Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016](https://reader036.fdocuments.net/reader036/viewer/2022081323/58f27c3a1a28abbd798b4635/html5/thumbnails/9.jpg)
![Page 10: Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016](https://reader036.fdocuments.net/reader036/viewer/2022081323/58f27c3a1a28abbd798b4635/html5/thumbnails/10.jpg)
Alan Key and OOP«... I thought of objects being like biological cells and/or individual computers on a network, only able to communicate with messages (so messaging came at the very beginning -- it took a while to see how to do messaging in a programming language efficiently enough to be useful).»
«... OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things.»
http://userpage.fu-berlin.de/~ram/pub/pub_jf47ht81Ht/doc_kay_oop_en
![Page 11: Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016](https://reader036.fdocuments.net/reader036/viewer/2022081323/58f27c3a1a28abbd798b4635/html5/thumbnails/11.jpg)
Alan Key and OOP«... I thought of objects being like biological cells and/or individual computers on a network, only able to communicate with messages (so messaging came at the very beginning -- it took a while to see how to do messaging in a programming language efficiently enough to be useful).»
«... OOP to me means only messaging, local retention and protection and hiding of state-process, and extreme late-binding of all things.»
http://userpage.fu-berlin.de/~ram/pub/pub_jf47ht81Ht/doc_kay_oop_en
![Page 12: Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016](https://reader036.fdocuments.net/reader036/viewer/2022081323/58f27c3a1a28abbd798b4635/html5/thumbnails/12.jpg)
![Page 13: Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016](https://reader036.fdocuments.net/reader036/viewer/2022081323/58f27c3a1a28abbd798b4635/html5/thumbnails/13.jpg)
![Page 14: Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016](https://reader036.fdocuments.net/reader036/viewer/2022081323/58f27c3a1a28abbd798b4635/html5/thumbnails/14.jpg)
Implementations
• Erlang
• Akka (Scala / Java)
• Orleans
• Akka.Net
• Reliable Actors (Azure Service Fabric)
![Page 15: Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016](https://reader036.fdocuments.net/reader036/viewer/2022081323/58f27c3a1a28abbd798b4635/html5/thumbnails/15.jpg)
![Page 16: Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016](https://reader036.fdocuments.net/reader036/viewer/2022081323/58f27c3a1a28abbd798b4635/html5/thumbnails/16.jpg)
Akka.Net
Akka
Akka.DI
Akka.Logger
Akka.Remote
Akka.Cluster
Akka.Persistence
![Page 17: Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016](https://reader036.fdocuments.net/reader036/viewer/2022081323/58f27c3a1a28abbd798b4635/html5/thumbnails/17.jpg)
Ok…so what is an actor?
![Page 18: Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016](https://reader036.fdocuments.net/reader036/viewer/2022081323/58f27c3a1a28abbd798b4635/html5/thumbnails/18.jpg)
DEMOIntro to Akka.NET
![Page 19: Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016](https://reader036.fdocuments.net/reader036/viewer/2022081323/58f27c3a1a28abbd798b4635/html5/thumbnails/19.jpg)
/
/user /system
/actor1
/child1 /child2 /child3
• Hierarchy
• ActorSelection
• Supervisor Strategy
![Page 20: Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016](https://reader036.fdocuments.net/reader036/viewer/2022081323/58f27c3a1a28abbd798b4635/html5/thumbnails/20.jpg)
DEMO
![Page 21: Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016](https://reader036.fdocuments.net/reader036/viewer/2022081323/58f27c3a1a28abbd798b4635/html5/thumbnails/21.jpg)
Reliable ActorsAzure Service Fabric
![Page 22: Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016](https://reader036.fdocuments.net/reader036/viewer/2022081323/58f27c3a1a28abbd798b4635/html5/thumbnails/22.jpg)
Reliable Actors
• Virtual Actor Model: actor’s lifetime is not tied to their in-memory representation
• Each Reliable Actor service is a partitioned, stateful Reliable Service
• To provide scalability and reliability, Service Fabric distributes actors throughout the cluster and automatically migrates them from failed nodes to healthy ones as required
![Page 23: Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016](https://reader036.fdocuments.net/reader036/viewer/2022081323/58f27c3a1a28abbd798b4635/html5/thumbnails/23.jpg)
DEMOIntro to Reliable Actors
![Page 24: Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016](https://reader036.fdocuments.net/reader036/viewer/2022081323/58f27c3a1a28abbd798b4635/html5/thumbnails/24.jpg)
![Page 25: Un actor (model) per amico - Alessandro Melchiori - Codemotion Milan 2016](https://reader036.fdocuments.net/reader036/viewer/2022081323/58f27c3a1a28abbd798b4635/html5/thumbnails/25.jpg)
Thank you! Questions?