so I am thinking of using the actor model to solve a problem I currently have. For brevity, I have made up a scenario so we don’t get too technical.
Lets say I have 3 benches but each bench supports a different amount of people:
- Park Bench 1 supports 3 people simultaneously
- Park Bench 2 supports 5 people simultaneously
- Park Bench 3 supports 2 people simultaneously
Upfront I know which bench to route too however, what I don’t have context of is how many people are sitting on the bench. What I want to do is block any further people from sitting on a bench if its full but when a seat becomes available allow them to sit on it.
For some reason, the Actor model popped into my head but I am not sure whether this is the correct approach and perhaps there is alternative approach to solving my problem in which case I am keen to hear.
I envision creating 3 actors ParkBench1Actor
ParkBench2Actor
ParkBench3Actor
and somehow control the number of live actors. I believe concepts such as pooling can help in these scenarios http://getakka.net/articles/actors/routers.html#pools-vs-groups.
Would appreciate peoples thoughts on this and tell me whether I have lost the plot a little 🙂
1
The actor model is distinguished from other techniques by virtue of its ability to run processes on any arbitrary machine within your computing domain. So if this capability fits your use case, then yes, it is ideal for your purposes.
However, a process is a relatively coarse-grained computational unit, and because of that, it’s not appropriate for all scenarios. You wouldn’t, for example, try to distribute the sorting of an ordinary array to actors unless the array was enormous. Instead, you would employ a finer-grained mechanism like threads and futures.
Map/Reduce engines like Hadoop/Hive (which take a big-data problem, break it into smaller pieces, fan it out to multiple machines and then perform an aggregation on the individual results) do justify a process-based, Actor-like model due to the huge amount of data involved.
6