What is nice about actors is that it mimics communication between persons in real life, so it sometimes makes it easier to model your domain using this approach. Harder things like eventual consistency etc are easy using actors, as you only have a mailbox to communicate.
In a way actors are an OO approach to software architecture: polymorphism, isolation, encapsulation and messaging are all baked in by definition.
As Alan Kay pointed out, OO was much more about messaging then about objects, and somehow that cornerstone got lost during the years after the initial conception.
About the instance/aggregate: that can/is usually the easiest way to implement it, and it works quite well. A typical example that should give you an idea of how to use actors (in Erlang or Elixir), would be to have one instance per client session for a web server, the guys from whatsapp even have a POC that allows 2 million concurrent client connections communicating over websockets on a single machine.
So, one actor/aggregate would work out just fine in Erlang IMO; you can always load and unload instances if you are running into memory problems.
But, please do note that the Erlang VM is optimized for a lot of small concurrent soft-realtime processes; it has things like local garbage collection, small (200-word-size) overhead/process, and lots of other optimizations.
Also, there is a framework available in Erlang that is like a higher-level library for actors, which allows you to setup FSM's, Servers, Supervisors, Event Servers etc...
Without these libraries - which have multiple decades of man-hours in it -, the actor model kind of works, but it is not truly as elegant and resistant to failures as other actor implementations.
One of the key features actors implementations seem to miss in non-erlang systems, is the whole supervision thing; in Erlang, you typically start out architecting your application by posing the question: "How do I want my app to crash?". If an instance crashes, it will be auto-restarted, within reasonable limits you define yourself. This allows you to remove all the cruft like error-checking, validation etc out of your implementation code, and centralize it.
This approach might seem odd to grasp, but once you get it, it seems odd not to have it; this is a bit hard to explain.
Usually combining this approach with things like pattern-matching etc lead to REALLY succinct code which hardly contains any non-relevant domain code at all...
So, TL;DR: yes, use one actor/instance.
Op zondag 29 september 2013 06:17:04 UTC+2 schreef Bennie Kloosteman: