Original link: http://blog.jeoygin.org/archives/477
Actor this model was presented by Carl Hewitt in 1973, Gul Agha published in 1986 the technical Report "Actors:a Model of Concurrent Computation in distributed Systems", It has been a few years now. In computer science, it is a mathematical model of parallel Computing, originally developed by a high parallel computer consisting of a large number of independent microprocessors, the concept of the Actor model is very simple: all things are actors in the world.
The actor communicates by sending a message, and the message is delivered asynchronously, and the message is processed through a mail queue. Each actor is completely independent and can perform their operations at the same time. Each actor is a computed entity that maps the received message to the following action:
- Send a limited message to other actors;
- Create a limited number of new actors;
- Specifies the behavior for the next received message.
The above three actions are not in a fixed order and can be executed concurrently. The actor is treated differently depending on the message received.
In an actor system, contains an unhandled set of tasks, each of which is identified by the following three properties:
- Tag: Used to differentiate from other tasks in the system;
- Target: The address at which the communication arrives;
- Communication: Contains information that can be obtained when the actor handles a task on target.
For simplicity, you can treat a task as a message, passing a message that contains the values of the above three attributes between actors.
The actor model has two kinds of task scheduling methods: thread-based scheduling and event-based scheduling:
- Thread-based scheduling: assigns a thread to each actor and, when receiving a message, blocks the current thread if the mailbox (mail box) of the current actor is empty. The implementation of thread-based scheduling is relatively simple, but the number of threads is limited by the operation, and now the actor model is generally not used in this way;
- Event-based debugging: An event can be understood as the arrival of a task or message, and the actor's task is assigned a thread and executed at this time.
In conclusion, we know that everything in the system can be abstracted into an actor:
- The input to the actor is the received message.
- The actor receives the message and processes the task defined in the message.
- The actor can send messages to other actors when it finishes the task.
Then in one system, a large-scale task can be decomposed into small tasks, which can be processed concurrently by multiple actors, thus reducing the time to complete a task.
For example, for example, to run a wordcount job on 3 physical nodes now, you can subdivide this job into split, count, and merge three tasks (the target of the task is the address of the physical node, communication may contain text, Words and counting, etc.), the split actor, Count Actor, and merge actor are required on demand. The process for the entire job is as follows:
- When the split Actor receives the message, it can split the text into 10 copies, each sent to a count Actor;
- The Count Actor counts the number of words and sends a message to the merge Actor;
- When the merge actor collects the 10 messages sent by the Count actor, merges the number of each word and completes the WordCount task.
As can be seen from the above example, the actor system is similar to a data-driven system such as data flow, and can customize the flow direction and process of the task. The actor model is widely used in many concurrent systems, such as email, Web service, and so on.
Resources
(1) G. Agha, Actors:a Model of Concurrent computation in distributed Systems. Cambridge, MA, Sa:mit press,1986.
(2) Wikipedia:http://en.wikipedia.org/wiki/actor_model
(3) Actorlite: A Lightweight Actor model implementation (UP)
Actor model [go]