When should one use the Actor model?

Viewed 11809

When should the Actor Model be used?

It certainly doesn't guarantee deadlock-free environment.

Actor A can wait for a message from B while B waits for A.

Also, if an actor has to make sure its message was processed before moving on to its next task, it will have to send a message and wait for a "your message was processed" message instead of the straightforward blocking.

What's the power of the model?

4 Answers

I am not an actor expert but here is my 2 cents when to use actor model: Actor model is not suited for every concurrent application, for instance if you are creating an application which is multi threaded and works in high concurrency actor model is not made to solve the concurrency issue. Where actors really comes into play is when you are creating an event driven application. For instance you have an application and you are tracking what are users clicking in your application realtime. You can use actors to do activities realtime segregated by user, device or anything of your business requirement as actors are stateful. So, for example if some users lies in actors which clicked on shirts you can send them notification of some coupon. Also some applications where actors comes handy are : Finance (Pricing, fraud detection), multiplayer gaming.

Actors are asynchronous and concurrent but does not guarantee message order or time limit as to when the message may be acted upon. Hence atomic transactions cannot be split into Actors.

If the application/task involves no mutable state then Actors are overkill as Actor frameworks go to great lengths to avoid race conditions.

Related