2014-10-07 93 views
1

嗨,因为我无法正确解决这个问题,这可能不是我的问题的正确标题,但在这种情况下;阿卡演员阻止邮件

演员A创建演员B1,演员B1创建负责执行任务的“n”演员。 所以A是B1的父母,B1是父母的可以说b1,b2,b3,...

在A我安排了一个代码,以便A检查每10secods是否有一个新的B'创建。

Duration duration = Duration.create(10 sec.); 
FiniteDuration interval = new FiniteDuration(duration.toMillis(), TimeUnit.MILLISECONDS); 
ticker = getContext().system().scheduler().schedule(interval, interval, getSelf(), new Tick() { }, getContext().dispatcher(), getSelf()); 

在前端我可以调整“b”任务的并行度数。 例如,如果我将平行度设置为3,则B(1)创建3个演员,并且每个演员执行一些任务 ,并且如果创建了一个演员,比如b(n),则完成比b(n + 1)上。

问题是;

如果只有一个演员b(i = 1)由演员“B”创建(B不重要)比ticker真的每10秒钟滴答 ,但是如果我增加b的平行度让我们说64 b(i = 64),那么代价不合适。 例如1分钟等待相当长的时间。然后连续滴6次,好像有一个冲水机构。

这并不是我在增加系统中的参与者数量时遇到的唯一问题。

我有一个API,以便用户发送订单演员像下面

String path = ActorPaths.actorPathForPlan(plan); 
ActorSelection actorSelection = runtimeInit.getSystem().actorSelection(path); 
// ask 
Timeout timeout = new Timeout(Duration.create(4*1000, TimeUnit.MILLISECONDS)); 
Future<Object> future = Patterns.ask(actorSelection, message, timeout); 
// get result 
return returnType.cast(Await.result(future, timeout.duration())); 

时,有超过approximitely 10的演员则期货总是超时,但是当我调试的代码,我看到消息 被recived但经过相当长的时间。

所以,我想知道什么阻止我的演员A接收消息。同样的问题可能发生在演员B'和其子 我还没有检查,但如果我找出问题,我相信我可以将解决方案应用到其他人。

感谢您的任何建议。

的hiararchy是这样

http://i.stack.imgur.com/PRmwE.png

回答

2

默认所有阿卡演员使用哪个被限制为使用64个线程最大同一执行。从http://doc.akka.io/docs/akka/snapshot/general/configuration.html

# This will be used if you have set "executor = "default-executor"". 
     # If an ActorSystem is created with a given ExecutionContext, this 
     # ExecutionContext will be used as the default executor for all 
     # dispatchers in the ActorSystem configured with 
     # executor = "default-executor". Note that "default-executor" 
     # is the default value for executor, and therefore used if not 
     # specified otherwise. If no ExecutionContext is given, 
     # the executor configured in "fallback" will be used. 
     default-executor { 
     fallback = "fork-join-executor" 
     } 

     # This will be used if you have set "executor = "fork-join-executor"" 
     fork-join-executor { 
     # Min number of threads to cap factor-based parallelism number to 
     parallelism-min = 8 

     # The parallelism factor is used to determine thread pool size using the 
     # following formula: ceil(available processors * factor). Resulting size 
     # is then bounded by the parallelism-min and parallelism-max values. 
     parallelism-factor = 3.0 

     # Max number of threads to cap factor-based parallelism number to 
     parallelism-max = 64 
     } 

该问题可能与阻止b * actors中的调用有关。 Akka从64个池中分配单独的线程来处理b * actors中的这些阻塞调用,并等待其中一个完成消息处理,以便能够处理A和B的消息。

请参见“阻止需要小心管理”在http://doc.akka.io/docs/akka/snapshot/general/actor-systems.html的想法如何解决这个问题。

+0

我改变了关于你的帖子的配置,并执行了一些测试。看看结果你似乎是对的。你的建议节省了很多时间来指出问题。非常感谢。 – whb 2014-10-08 16:19:10