Why is my "Actor Manager" reduced in Akka?

I have an actor pool of 100 Acting Actors that share the theft manager with its CorePoolSize set to 100. But now, sending 19 messages to one of the Actors, 19 messages are not parallelized with 19 Actors, there are only 5 messages working in parallel. When these 5 messages are completed, the next 5 messages are processed by the same 5 Actors again and so on. Why are my 19 messages not working in parallel, what am I missing here?

My code looks basically like this:

object TestActor { val dispatcher = Dispatchers.newExecutorBasedEventDrivenWorkStealingDispatcher("pool") .setCorePoolSize(100) .setMaxPoolSize(100) .build } class TestActor(val name: Integer) extends Actor { self.lifeCycle = Permanent self.dispatcher = TestActor.dispatcher def receive = { case num: Integer => { println("Actor: " + name + " Received: " + num) Thread.sleep(10000) } } } trait CyclicLoadBalancing extends LoadBalancer { this: Actor => val testActors: List[ActorRef] val seq = new CyclicIterator[ActorRef](testActors) } trait TestActorManager extends Actor { self.lifeCycle = Permanent self.faultHandler = OneForOneStrategy(List(classOf[Exception]), 5, 5000) val testActors: List[ActorRef] override def preStart = testActors foreach { self.startLink(_) } override def postStop = self.shutdownLinkedActors() } val supervisor = actorOf(new TestActorManager with CyclicLoadBalancing { val testActors = (1 until 100 toList) map (i => actorOf(new TestActor(i))) }).start println("Number of Actors: " + Actor.registry.actorsFor(classOf[TestActor]).length) val testActor = Actor.registry.actorsFor(classOf[TestActor]).head (1 until 20 toList) foreach { testActor ! _ } 

Exit:

 Actor: 4 Received: 16 Actor: 3 Received: 17 Actor: 1 Received: 19 Actor: 59 Received: 1 Actor: 2 Received: 18 // 10 secs. are passing.. Actor: 4 Received: 15 Actor: 3 Received: 14 Actor: 1 Received: 13 Actor: 59 Received: 2 Actor: 2 Received: 12 // 10 secs. are passing.. Actor: 4 Received: 11 Actor: 3 Received: 10 Actor: 59 Received: 3 Actor: 2 Received: 8 Actor: 1 Received: 9 // 10 secs. are passing.. Actor: 4 Received: 7 Actor: 3 Received: 6 Actor: 59 Received: 4 Actor: 2 Received: 5 

edit: I am using Akka 1.0

+8
scala akka
source share
2 answers

thanks for your request, I localized the bottleneck and fixed it in this commit for the Akka master:

https://github.com/akka/akka/commit/e4e99ef56399e892206ce4a46b9a9107da6c7770

It will be released in Akka 1.1-RC1

Cheers, √

+12
source share

I think the dispatcher allows you to configure the bandwidth. This determines the number of messages for a particular Actor, which the dispatcher should process in one run. You can add the following configuration to your akka.conf file

 actor { throughput = 20 } 

The default is 5

+2
source share

All Articles