2014-10-07 94 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