Java 阿克卡演员封锁消息

Java 阿克卡演员封锁消息,java,concurrency,akka,actor,Java,Concurrency,Akka,Actor,您好,因为我无法正确地解决问题,这可能不是我问题的正确标题,但情况就是这样 参与者A创建参与者B1,参与者B1创建负责执行任务的“n”个参与者。 所以A是B1的母函数,B1是B1,b2,b3,…,的母函数 在A中,我已经安排了一个计时器,以便A每10秒检查一次是否有新的B'要创建 Duration duration = Duration.create(10 sec.); FiniteDuration interval = new FiniteDuration(duration.toMillis(

您好,因为我无法正确地解决问题,这可能不是我问题的正确标题,但情况就是这样

参与者A创建参与者B1,参与者B1创建负责执行任务的“n”个参与者。 所以A是B1的母函数,B1是B1,b2,b3,…,的母函数

在A中,我已经安排了一个计时器,以便A每10秒检查一次是否有新的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的平行度增加到64B(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()));
String path=ActorPaths.actorPathForPlan(plan);
ActorSelection ActorSelection=runtimeInit.getSystem().ActorSelection(路径);
//问
Timeout Timeout=新的超时(Duration.create(4*1000,TimeUnit.ms));
Future=Patterns.ask(actorSelection、message、timeout);
//得到结果
返回returnType.cast(wait.result(future,timeout.duration());
当有大约10个以上的参与者时,futures总是超时,但当我调试代码时,我看到了消息 收到了,但过了相当长的时间

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

谢谢你的建议

海拉尔希是这样的


默认情况下,所有Akka参与者都使用同一个执行器,最多只能使用64个线程。发件人:

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


请参阅中的“阻塞需要仔细管理”,以了解如何解决此问题。

我已更改了有关您的帖子的配置,并执行了一些测试。看看结果,你似乎是对的。你的建议节省了很多时间来指出这个问题。谢谢。
# 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
      }