0

I am trying to figure out how Akka works and what are the best practices for using Actor Model.

I have couple of questions regarding the same.

Questions:

  1. What are the deciding factors that we should keep in mind when configuring total number of Actors and Threads for below mentioned scenario?

    Scenarios:

    a. only tell is being invoked on actor (Fire and Forget).

    b. ask is being invoked (Futures and Promise).

  2. What are the advantage/disadvantage of using Router e.g RoundRobinRouter(X) over manual actors creation.

  3. How dispatcher orchestrates MailBox, Actor and Threads for message processing.

Atul
  • 1,694
  • 4
  • 21
  • 30

1 Answers1

1

Futures and Promises can be used independent of Actors and routers. Also the Alvin Alexander link below does a great job comparing Futures/Promises to Threads (which are the same as in Java).

The type of routing you should use will depend on your specific application need. In general you should choose a routing technique that mirrors the real-world problem you are trying to solve. E.g. is it more like a mailbox or bus/broadcast, or a round-robin.

If you don't use the built-in routers offered by Akka, then you might be tempted to write your own router. However it might be hard for you to improve on the Akka library: in the akka.io docs below, they explain that some of the routing work is delegated to the actors by the library, to deal with the fact that the router is single-threaded.

A typical computer will let you launch thousands of threads or actors if you have several gigabytes of RAM. However at any one moment, the number of threads actually running won't be more than the number of cores you have in your CPU.

Here are some articles that might help you decide which techniques to use and how many threads and actors are appropriate:

http://doc.akka.io/docs/akka/2.4.10/scala/routing.html

Akka messaging mechanisms by example

How many actors can be launched in scala?

http://alvinalexander.com/scala/differences-java-thread-vs-scala-future

How many threads can ran on a CPU at a time

Community
  • 1
  • 1
akubot
  • 141
  • 1
  • 8