Actor model


The actor model in computer science is a mathematical model of concurrent computation that treats actor as the universal primitive of concurrent computation. In response to a message it receives, an actor can: make local decisions, create more actors, send more messages, and determine how to respond to the next message received. Actors may modify their own private state, but can only affect each other indirectly through messaging.
The actor model originated in 1973. It has been used both as a framework for a theoretical understanding of computation and as the theoretical basis for several practical implementations of concurrent systems. The relationship of the model to other work is discussed in actor model and process calculi.

History

According to Carl Hewitt, unlike previous models of computation, the actor model was inspired by physics, including general relativity and quantum mechanics. It was also influenced by the programming languages Lisp, Simula, early versions of Smalltalk, capability-based systems, and packet switching. Its development was "motivated by the prospect of highly parallel computing machines consisting of dozens, hundreds, or even thousands of independent microprocessors, each with its own local memory and communications processor, communicating via a high-performance communications network." Since that time, the advent of massive concurrency through multi-core and manycore computer architectures has revived interest in the actor model.
Following Hewitt, Bishop, and Steiger's 1973 publication, Irene Greif developed an operational semantics for the actor model as part of her doctoral research. Two years later, Henry Baker and Hewitt published a set of axiomatic laws for actor systems. Other major milestones include William Clinger's 1981 dissertation introducing a denotational semantics based on power domains and Gul Agha's 1985 dissertation which further developed a transition-based semantic model complementary to Clinger's. This resulted in the full development of actor model theory.
Major software implementation work was done by Russ Atkinson, Giuseppe Attardi, Henry Baker, Gerry Barber, Peter Bishop, Peter de Jong, Ken Kahn, Henry Lieberman, Carl Manning, Tom Reinhardt, Richard Steiger and Dan Theriault in the Message Passing Semantics Group at Massachusetts Institute of Technology. Research groups led by Chuck Seitz at California Institute of Technology and Bill Dally at MIT constructed computer architectures that further developed the message passing in the model. See Actor model implementation.
Research on the actor model has been carried out at California Institute of Technology, Kyoto University Tokoro Laboratory, Microelectronics and Computer Technology Corporation, MIT Artificial Intelligence Laboratory, SRI, Stanford University, University of Illinois at Urbana–Champaign, Pierre and Marie Curie University, University of Pisa, University of Tokyo Yonezawa Laboratory, Centrum Wiskunde & Informatica and elsewhere.

Fundamental concepts

The actor model adopts the philosophy that everything is an actor. This is similar to the everything is an object philosophy used by some object-oriented programming languages.
An actor is a computational entity that, in response to a message it receives, can concurrently:
There is no assumed sequence to the above actions and they could be carried out in parallel.
Decoupling the sender from communications sent was a fundamental advance of the actor model enabling asynchronous communication and control structures as patterns of passing messages.
Recipients of messages are identified by address, sometimes called "mailing address". Thus an actor can only communicate with actors whose addresses it has. It can obtain those from a message it receives, or if the address is for an actor it has itself created.
The actor model is characterized by inherent concurrency of computation within and among actors, dynamic creation of actors, inclusion of actor addresses in messages, and interaction only through direct asynchronous message passing with no restriction on message arrival order.

Formal systems

Over the years, several different formal systems have been developed which permit reasoning about systems in the actor model. These include:
There are also formalisms that are not fully faithful to the actor model in that they do not formalize the guaranteed delivery of messages including the following :
The actor model can be used as a framework for modeling, understanding, and reasoning about a wide range of concurrent systems. For example:
The actor model is about the semantics of message passing.

Unbounded nondeterminism controversy

Arguably, the first concurrent programs were interrupt handlers. During the course of its normal operation a computer needed to be able to receive information from outside. So when the information arrived the execution of the computer was interrupted and special code was called to put the information in a data buffer where it could be subsequently retrieved.
In the early 1960s, interrupts began to be used to simulate the concurrent execution of several programs on one processor. Having concurrency with shared memory gave rise to the problem of concurrency control. Originally, this problem was conceived as being one of mutual exclusion on a single computer. Edsger Dijkstra developed semaphores and later, between 1971 and 1973, Tony Hoare and Per Brinch Hansen developed monitors to solve the mutual exclusion problem. However, neither of these solutions provided a programming language construct that encapsulated access to shared resources. This encapsulation was later accomplished by the serializer construct.
The first models of computation were based on mathematics and made use of a global state to represent a computational step. Each computational step was from one global state of the computation to the next global state. The global state approach was continued in automata theory for finite-state machines and push down stack machines, including their nondeterministic versions. Such nondeterministic automata have the property of bounded nondeterminism; that is, if a machine always halts when started in its initial state, then there is a bound on the number of states in which it halts.
Edsger Dijkstra further developed the nondeterministic global state approach. Dijkstra's model gave rise to a controversy concerning unbounded nondeterminism, a property of concurrency by which the amount of delay in servicing a request can become unbounded as a result of arbitration of contention for shared resources while still guaranteeing that the request will eventually be serviced. Hewitt argued that the actor model should provide the guarantee of service. In Dijkstra's model, although there could be an unbounded amount of time between the execution of sequential instructions on a computer, a program that started out in a well defined state could terminate in only a bounded number of states . Consequently, his model could not provide the guarantee of service. Dijkstra argued that it was impossible to implement unbounded nondeterminism.
Hewitt argued otherwise: there is no bound that can be placed on how long it takes a computational circuit called an arbiter to settle. Arbiters are used in computers to deal with the circumstance that computer clocks operate asynchronously with respect to input from outside, e.g., keyboard input, disk access, network input, etc. So it could take an unbounded time for a message sent to a computer to be received and in the meantime the computer could traverse an unbounded number of states.
The actor model features unbounded nondeterminism which was captured in a mathematical model by Will Clinger using domain theory. In the actor model, there is no global state.

Direct communication and asynchrony

Messages in the actor model are not necessarily buffered. This was a sharp break with previous approaches to models of concurrent computation. The lack of buffering caused a great deal of misunderstanding at the time of the development of the actor model and is still a controversial issue. Some researchers argued that the messages are buffered in the "ether" or the "environment". Also, messages in the actor model are simply sent ; there is no requirement for a synchronous handshake with the recipient.

Actor creation plus addresses in messages means variable topology

A natural development of the actor model was to allow addresses in messages. Influenced by packet switched networks , Hewitt proposed the development of a new model of concurrent computation in which communications would not have any required fields at all: they could be empty. Of course, if the sender of a communication desired a recipient to have access to addresses which the recipient did not already have, the address would have to be sent in the communication.
For example, an actor might need to send a message to a recipient actor from which it later expects to receive a response, but the response will actually be handled by a third actor component that has been configured to receive and handle the response. The original actor could accomplish this by sending a communication that includes the message it wishes to send, along with the address of the third actor that will handle the response. This third actor that will handle the response is called the resumption. When the recipient actor is ready to send a response, it sends the response message to the resumption actor address that was included in the original communication.
So, the ability of actors to create new actors with which they can exchange communications, along with the ability to include the addresses of other actors in messages, gives actors the ability to create and participate in arbitrarily variable topological relationships with one another, much as the objects in Simula and other object-oriented languages may also be relationally composed into variable topologies of message-exchanging objects.

Inherently concurrent

As opposed to the previous approach based on composing sequential processes, the actor model was developed as an inherently concurrent model. In the actor model sequentiality was a special case that derived from concurrent computation as explained in actor model theory.

No requirement on order of message arrival

Hewitt argued against adding the requirement that messages must arrive in the order in which they are sent to the actor. If output message ordering is desired, then it can be modeled by a queue actor that provides this functionality. Such a queue actor would queue the messages that arrived so that they could be retrieved in FIFO order. So if an actor X sent a message M1 to an actor Y, and later X sent another message M2 to Y, there is no requirement that M1 arrives at Y before M2.
In this respect the actor model mirrors packet switching systems which do not guarantee that packets must be received in the order sent. Not providing the order of delivery guarantee allows packet switching to buffer packets, use multiple paths to send packets, resend damaged packets, and to provide other optimizations.
For example, actors are allowed to pipeline the processing of messages. What this means is that in the course of processing a message M1, an actor can designate the behavior to be used to process the next message, and then in fact begin processing another message M2 before it has finished processing M1. Just because an actor is allowed to pipeline the processing of messages does not mean that it must pipeline the processing. Whether a message is pipelined is an engineering tradeoff. How would an external observer know whether the processing of a message by an actor has been pipelined? There is no ambiguity in the definition of an actor created by the possibility of pipelining. Of course, it is possible to perform the pipeline optimization incorrectly in some implementations, in which case unexpected behavior may occur.

Locality

Another important characteristic of the actor model is locality.
Locality means that in processing a message, an actor can send messages only to addresses that it receives in the message, addresses that it already had before it received the message, and addresses for actors that it creates while processing the message.
Also locality means that there is no simultaneous change in multiple locations. In this way it differs from some other models of concurrency, e.g., the Petri net model in which tokens are simultaneously removed from multiple locations and placed in other locations.

Composing actor systems

The idea of composing actor systems into larger ones is an important aspect of modularity that was developed in Gul Agha's doctoral dissertation, developed later by Gul Agha, Ian Mason, Scott Smith, and Carolyn Talcott.

Behaviors

A key innovation was the introduction of behavior specified as a mathematical function to express what an actor does when it processes a message, including specifying a new behavior to process the next message that arrives. Behaviors provided a mechanism to mathematically model the sharing in concurrency.
Behaviors also freed the actor model from implementation details, e.g., the Smalltalk-72 token stream interpreter. However, it is critical to understand that the efficient implementation of systems described by the actor model require extensive optimization. See Actor model implementation for details.

Modeling other concurrency systems

Other concurrency systems can be modeled in the actor model using a two-phase commit protocol.

Computational Representation Theorem

There is a Computational Representation Theorem in the actor model for systems which are closed in the sense that they do not receive communications from outside. The mathematical denotation denoted by a closed system S is constructed from an initial behavior S and a behavior-approximating function progressionS. These obtain increasingly better approximations and construct a denotation for S as follows :
In this way, S can be mathematically characterized in terms of all its possible behaviors. Although DenoteS is not an implementation of S, it can be used to prove a generalization of the Church-Turing-Rosser-Kleene thesis :
A consequence of the above theorem is that a finite actor can nondeterministically respond with an number of different outputs.

Relationship to logic programming

One of the key motivations for the development of the actor model was to understand and deal with the control structure issues that arose in development of the Planner programming language. Once the actor model was initially defined, an important challenge was to understand the power of the model relative to Robert Kowalski's thesis that "computation can be subsumed by deduction". Hewitt argued that Kowalski's thesis turned out to be false for the concurrent computation in the actor model.
Nevertheless, attempts were made to extend logic programming to concurrent computation. However, Hewitt and Agha claimed that the resulting systems were not deductive in the following sense: computational steps of the concurrent logic programming systems do not follow deductively from previous steps. Recently, logic programming has been integrated into the actor model in a way that maintains logical semantics.

Migration

Migration in the actor model is the ability of actors to change locations. E.g., in his dissertation, Aki Yonezawa modeled a post office that customer actors could enter, change locations within while operating, and exit. An actor that can migrate can be modeled by having a location actor that changes when the actor migrates. However the faithfulness of this modeling is controversial and the subject of research.

Security

The security of actors can be protected in the following ways:
A delicate point in the actor model is the ability to synthesize the address of an actor. In some cases security can be used to prevent the synthesis of addresses. However, if an actor address is simply a bit string then clearly it can be synthesized although it may be difficult or even infeasible to guess the address of an actor if the bit strings are long enough. SOAP uses a URL for the address of an endpoint where an actor can be reached. Since a URL is a character string, it can clearly be synthesized although encryption can make it virtually impossible to guess.
Synthesizing the addresses of actors is usually modeled using mapping. The idea is to use an actor system to perform the mapping to the actual actor addresses. For example, on a computer the memory structure of the computer can be modeled as an actor system that does the mapping. In the case of SOAP addresses, it's modeling the DNS and the rest of the URL mapping.

Contrast with other models of message-passing concurrency

's initial published work on concurrency was also notable in that it was not based on composing sequential processes. His work differed from the actor model because it was based on a fixed number of processes of fixed topology communicating numbers and strings using synchronous communication. The original communicating sequential processes model published by Tony Hoare differed from the actor model because it was based on the parallel composition of a fixed number of sequential processes connected in a fixed topology, and communicating using synchronous message-passing based on process names. Later versions of CSP abandoned communication based on process names in favor of anonymous communication via channels, an approach also used in Milner's work on the calculus of communicating systems and the π-calculus.
These early models by Milner and Hoare both had the property of bounded nondeterminism. Modern, theoretical CSP explicitly provides unbounded nondeterminism.
Petri nets and their extensions are like actors in that they are based on asynchronous message passing and unbounded nondeterminism, while they are like early CSP in that they define fixed topologies of elementary processing steps and message repositories.

Influence

The actor model has been influential on both theory development and practical software development.

Theory

The actor model has influenced the development of the π-calculus and subsequent process calculi. In his Turing lecture, Robin Milner wrote:
Now, the pure lambda-calculus is built with just two kinds of thing: terms and variables. Can we achieve the same economy for a process calculus? Carl Hewitt, with his actors model, responded to this challenge long ago; he declared that a value, an operator on values, and a process should all be the same kind of thing: an actor.
This goal impressed me, because it implies the homogeneity and completeness of expression... But it was long before I could see how to attain the goal in terms of an algebraic calculus...
So, in the spirit of Hewitt, our first step is to demand that all things denoted by terms or accessed by names—values, registers, operators, processes, objects—are all of the same kind of thing; they should all be processes.

Practice

The actor model has had extensive influence on commercial practice. For example, Twitter has used actors for scalability. Also, Microsoft has used the actor model in the development of its Asynchronous Agents Library. There are many other actor libraries listed in the actor libraries and frameworks section below.

Addressed issues

According to Hewitt , the actor model addresses issues in computer and communications architecture, concurrent programming languages, and Web services including the following:
Many of the ideas introduced in the actor model are now also finding application in multi-agent systems for these same reasons . The key difference is that agent systems impose extra constraints upon the actors, typically requiring that they make use of commitments and goals.

Programming with actors

A number of different programming languages employ the actor model or some variation of it. These languages include:

Early actor programming languages

Actor libraries or frameworks have also been implemented to permit actor-style programming in languages that don't have actors built-in. Some of these frameworks are:
NameStatusLatest releaseLicenseLanguages
2020-04-16Apache-2.0 / MITRust
2020-03-21MITRust
2019-05-30MITRust
2016-10-17MITSwift
2017-03-09MITJava
2020-01-31Apache 2.0Java
2019-04-09Apache 2.0Java
2018-02-13Apache 2.0Java, Groovy, Javascript, Ruby, Scala, Kotlin, Ceylon
2013-11-13Apache 2.0.NET
Akka 2019-05-21Apache 2.0Java and Scala
2018-12-18Apache 2.0.NET
2016-06-26MIT.NET, Javascript
??Java
2016-11-10MPL-2C
same as F# Apache LicenseF#
2010-02-04GPL 3Java
2018-11-09MITJava
ActorFoundry 2008-12-28?Java
2011-09-13BSDObjective-C
2015-06-17BSDHaskell
2018-12-19MITC/C++, Elixir/Erlang/LFE, Go, Haskell, Java, Javascript, OCaml, Perl, PHP, Python, Ruby
2017-05-12 LGPL 2.1C, C++, Python, Perl
2012-02-28 LGPL 3.0.NET
2018-06-06Apache 2.0JavaScript/ReasonML
2011-05-18New BSD.NET
2013-01-22LGPLJava
2013-05-30New BSDJava
2008New BSDHaskell
2014-05-09Apache 2.0Groovy
2019-05-09GPL 2.0 and commercial C. C++ friendly
2014-05-22MPL 1.1Programming Language by itself
2007-22-07GPL 2.1Python
2007-06-29LGPL 3.0Java
2014-09-24Commercial / Freemium.NET
2016-07-09New BSDPython
2016-02-18LGPL/EclipseClojure
2019-05-07Apache 2.0Python
2009-05-21LGPLScheme
2014-01-18MITC++
2020-03-10MITPython
2018-11-02LGPL/EclipseJava
2009 GPL 2.0C
2012-03-10GPL 2.0C++
2012-07-31Apache 2.0Java
2020-02-08Boost Software License 1.0 and BSD 3-ClauseC++11
2018-12-20MITRuby
2012-03-01LabVIEW
2016-06-01BSDLabVIEW
2019-05-28New BSDJava
QP frameworks for real-time embedded systems2019-05-25GPL 2.0 and commercial C and C++
2013-06-19Apache 2.0C++
2020-05-09New BSDC++11
2019-07-24MIT LicenseC++17
2019-06-02MIT LicenseC#/.NET
2016-07-11MIT LicenseC/Lua
2016-06-14BSD LicenseJava/Scala
2020-03-08Free software licenseC++11
2018-09-22Free software licenseGo, C#, Python, JavaScript, Java, Kotlin
2018-08-18BSD 3-ClauseJava
2019-01-04MIT LicenseRust
2019-03-09EPL 1.0JavaScript