Actor Models (Xy Ziemba)
Readings:
Read http://en.wikipedia.org/wiki/Actor_model
Sections:
1. History
2. Fundamental concepts
4. Applications
5. Message-passing semantics <-- skim this one
Reading Questions:
What inspired the Actor model? What aspects of the model remind you of this inspiration?
What other forms of handling concurrency are you aware of? Are actors higher or lower level than these forms?
What changes in computation might make the actor model more relevant today?
What does an actor receive?
What can an actor do once it has received a message?
Is an actor stateless?
Lecture notes:
What's wrong with threads?
Implementation varies with the platform
Deadlocks can occur
Not necessarily appropriate for distributed systems
What is the actor model?
Everything is an actor
Actors have state
Actors send and receive messages
Actors can create new actors
Why do we care about the actor model?
Distributed computation is rapidly becoming more relevant.
Actor models allow us to abstract distributed, multi-threaded processes away from a machine. (In effect, we can analyze these processes more theoretically.)
In class activities:
Download and set up http://pykka.readthedocs.org/en/latest/index.html
Copy the plain actor code on http://pykka.readthedocs.org/en/latest/introduction/#the-actor-model. Modify the code such that each PlainActor creates a ChildActor and relays all messages to it. You will need to create the ChildActor class.
Now, create a class called BinaryActor. A BinaryActor is an element of a binary tree. You should create one BinaryActor in your main class. This should then instantiate the tree of additional BinaryActors. Messages should be passed both down and up the tree.
Quiz questions:
Using Pykka, create a network of actors which distributes work for an arbitrary function "PythonPackage.hard_problem()"
Explain, in English, how this network of actors distributes the workload.
Explain what sort of problem you're optimizing for. What characteristics of PythonPackage.hard_problem() might make your actor structure appropriate? What characteristics might not?
Homework exercise:
Use the BinaryActor created in class to balance a hypothetical load tree. Your main function should generate variable amounts of time to pause a thread for. (Higher time is simulates a higher load.) This value should be passed down the tree and allocated to the leaf with the smallest backlog. You will have to send messages up and down the tree to update work backlogs.