Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Design patterns/best practice for building Actor-based system

People also ask

What is actor design pattern?

The basic Actor Model design pattern is simple. When you hear of an actor, think of it as a computer process or a function. It's some code that you're going to pass a message to, kind of like calling a function. Basically you send the actor instructions and it returns some information back to you.

What is actor based system?

The actor model can be used as a framework for modeling, understanding, and reasoning about a wide range of concurrent systems. For example: Electronic mail (email) can be modeled as an actor system. Accounts are modeled as actors and email addresses as actor addresses.

What is actor based concurrency?

The fundamental idea of the actor model is to use actors as concurrent primitives that can act upon receiving messages in different ways: Send a finite number of messages to other actors. Spawn a finite number of new actors. Change its own internal behavior, taking effect when the next incoming message is handled.

Do actors share memory?

The main difference is that actors are completely isolated from each other and they will never share memory. It's also worth noting that an actor can maintain a private state that can never be changed directly by another actor.


This is related to a previous question, if not exactly the same!

It's not such a simple question because the actor model of concurrency allows for many different types of applications to be built, from a stateful single-VM application (with a few separate actor classes) to a stateless cluster of thousands of instances of an actor class.

The core principles are the same however:

  • Never expose an actor's state
  • Communicate solely via the passing of immutable messages

I posted a blog on learnings of actor development in Scala a few weeks ago. It's a post of a best practices and things to avoid based on a few years of experience with the paradigm.


The book 'Reactive Design Patterns' is in the making at Manning.

See: https://www.manning.com/books/reactive-design-patterns