Understanding tuning akka dispatchers (by Jami allan)

瀏覽次數:73 次
跳到第一則未讀訊息

AL

未讀,
2017年10月15日 上午10:50:432017/10/15
收件者:Akka User List
Reading tuning akka dispatchers article by Jami allan. he writes:


If you suspect you will need to use a Router somewhere, 
Akka Team Lead Roland Kuhn recommends that you pass around actor references from supervisors to compute-intensive children so that the ‘context.parent’ of their children are free to become a router later on with minimal impact. But do not create Routers before you have proven at runtime under load that you absolutely need to.

can anyone elaborate on that with a simple example ? 

Thanks in advance

Rob Crawford

未讀,
2017年10月17日 上午9:34:172017/10/17
收件者:Akka User List
With the Java API, something like this:

public class ComputeIntensiveChild extends AbstactActor {
private final ActorRef realParent;

public static Props create(ActorRef realParent) {
    return Props.create(ComputeIntensiveChild.class, realParent);
}

public ComputeIntensiveChild(ActorRef realParent) {
    this.realParent = realParent;
}

public Receive createReceive() {
...
}

}

This way you send the answer to realParent instead of getContext().getParent(). Even if there's a router between the child and realParent, the intended recipient gets the message.

BUT I'm not sure this isn't a premature optimization. Since there's a possibility of a router in the mix, that means the child is sending a response to a message it received. In that case, just 
send the response to the sender -- routers always forward messages, preserving the original sender. 

AL

未讀,
2017年10月18日 上午11:09:452017/10/18
收件者:Akka User List
Thanks,
The scala API is different. but I am not sure that this is what he meant

Rob Crawford

未讀,
2017年10月18日 下午1:25:422017/10/18
收件者:Akka User List
What do you believe he meant?

AL

未讀,
2017年10月19日 上午11:21:442017/10/19
收件者:Akka User List
don't know really. I take my words back :)  what you wrote makes perfect sense. thanks

Roland Kuhn

未讀,
2017年10月20日 下午1:38:092017/10/20
收件者:akka...@googlegroups.com
Sorry for the long delay. Jamie’s advice combines two concerns, one has been explained by Rob, the other is that routers have historically been severely overused—they serve a very specific need that does not arise frequently.

Regards, Roland 

Sent from my iPhone
--
>>>>>>>>>> Read the docs: http://akka.io/docs/
>>>>>>>>>> Check the FAQ: http://doc.akka.io/docs/akka/current/additional/faq.html
>>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user
---
You received this message because you are subscribed to the Google Groups "Akka User List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to akka-user+...@googlegroups.com.
To post to this group, send email to akka...@googlegroups.com.
Visit this group at https://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.
回覆所有人
回覆作者
轉寄
0 則新訊息