DEV Community

Actor model vs Microservices

stereobooster on October 12, 2019

This idea happened recently to me: what if microservice is a reinvention of the wheel? What if microservices try to accomplish the same thing as ac...
Collapse
 
avalander profile image
Avalander • Edited

I think that the actor model and micro-services solve entirely different issues. The problem that micro-services solve is not parallelization of computations, but organizational scaling.

In a tech organization with 80 developers working on the same product, it's easier to split the services into mostly independent and self-contained smaller services than can be developed and maintained by a small team.

While it is technically possible to have everything in the same application and have every team commit to the same repository and deploy everything together, splitting it into smaller chunks gives each team more autonomy and the possibility to adapt and set up different processes for different services.

Collapse
 
redbar0n profile image
Magne

Actually, localised autonomy is also very important in the Actor model as well: youtu.be/e5kek8vx2ws?t=1593

So I think the overlap could be quite good.

Collapse
 
coreyoconnor profile image
Corey O'Connor • Edited

In reading a book about distributed systems (edit: see reply for details) I ran across a similar thread. Liked the idea so much I built an EDSL in Scala for this. Will official release in a free weeks. :) Here's what an example looks like:

Would love your thoughts on that example. :)

The getting started guide is being completed as I write this:

Collapse
 
coreyoconnor profile image
Corey O'Connor

The reference was: "Programming Distributed Computing Systems" by Varela (2013). On pg 172 they discuss a particular aspect of the SALSA (2001) programming language (a language by the same author):

"The ActorService ... is used to annotate behaviors whose instances are not to be garbage collected. The reason is that it is possible to create references to instance of behaviors implementing this interface from their [host and path]"

They proceed to describe how an instance of an ActorService would be routed using a host and path. They are, in effect, describing technology similar to a proxy plus service. However, their specific representation is inappropriate for microservices. Interesting tho :)

Collapse
 
vertigo profile image
Vertigo

"Right, but you need to store the information somewhere (accounts, records, users)? If you don’t count the database as service itself, the same logic can be applied to the actors."

Actors are stateful by having internal state (no pun). Microservices (if stateless), treat every request without (internal) knowledge of the past, while actors might carry state over to the next message (Hence one of their core principles is 'decide what to do with the next message').

Collapse
 
phlash profile image
Phil Ashby • Edited

I found the linked slides from Rotem Hermon enlightening:
speakerdeck.com/rore/actors-and-mi...

and I knew I'd seen something similar before, it was Microsoft's Orleans:
microsoft.com/en-us/research/proje...

In essence: the Actor Model (a mathematical concept from 1973) can be implemented as a set of services (micro, nano, chose your buzzword!), and that's what Orleans does to provide an opinionated, scaleable platform for developing parallel applications without all the inherent risks of rolling your own distributed architecture.

Other opinionated platforms that are similar: Map/Reduce, Apache Spark, AWS Lambda, all of which isolate/protect the developer from the details of distributing and scaling their code by placing some constraints on it (typically requiring stateless operation between instances).

The Actor Model can also be implemented in a non-distributed single application, allowing it to operate effectively on a multi-core processor without the inherent risks of writing your own multi-threaded software.

Some languages were designed to embody the Actor Model:
wiki.c2.com/?ActorLanguages

hope this helps!

Collapse
 
adam_cyclones profile image
Adam Crockett πŸŒ€

Thought provoking article, nice! Ps visited your blog to help you out, every little helps.

Collapse
 
stereobooster profile image
stereobooster

Thought provoking article

Thank you! This reaction is exactly what I hoped for.