The difference between actor model and CSP model

Source: Internet
Author: User

What is the difference between the actor model of Akka/erlang and the goroutine of the Go language and the CSP (communicating sequential Processes) model represented by channel channels?

First of all, both are solutions to the concurrency model, and let's look at how it's defined and implemented:

The actor model describes a set of axioms to avoid common problems with concurrent programming :

1. All actor states are actor-local and cannot be accessed externally.
2.Actor must communicate only through message delivery.
3. An actor can respond to a message: Launch a new actor, change its internal state, or send a message to one or more other participants.
4.Actor may clog itself, but the actor should not clog its running thread.

More Visible Actor Model topics

The communication between actors is realized through the intermediary of mailbox mailbox, the most important thing is that the actor does not know each other.

The CSP model for the Go language is implemented by the co-goroutine and channel channels:

    • Go goroutine: is a lightweight thread that is not a thread of the operating system , but rather a segmented use of an operating system thread to implement collaborative scheduling through the scheduler. is a green thread, a micro-thread, and it differs from the coroutine, enabling new micro-threading to be started after a blockage is found.
    • Channel channels: A UNIX-like pipe used for communication and synchronization between threads. Although decoupling between the processes, they are coupled to the channel.

The actor model and the CSP difference diagram are as follows:

They are all described as independent processes communicating through message delivery. The main difference is that the CSP message exchange is synchronous (that is, the execution of the two processes "touch points", where they exchange messages), and the actor model is fully decoupled and can be sent to any unconfirmed recipient at any time. Because the actor enjoys greater mutual independence, he can choose which incoming message to process according to his state. In the go language in order to not block process programmers must check for different incoming messages in order to anticipate ensuring the correct order. The CSP benefit is that the channel does not need to buffer the message, and the actor theoretically needs an infinite size mailbox as the message buffer.

The difference between actor model and CSP model

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.