Understanding tuning akka dispatchers (by Jami allan)

73 views
Skip to first unread message

AL

unread,
Oct 15, 2017, 10:50:43 AM10/15/17
to 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

unread,
Oct 17, 2017, 9:34:17 AM10/17/17
to 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

unread,
Oct 18, 2017, 11:09:45 AM10/18/17
to Akka User List
Thanks,
The scala API is different. but I am not sure that this is what he meant

Rob Crawford

unread,
Oct 18, 2017, 1:25:42 PM10/18/17
to Akka User List
What do you believe he meant?

AL

unread,
Oct 19, 2017, 11:21:44 AM10/19/17
to Akka User List
don't know really. I take my words back :)  what you wrote makes perfect sense. thanks

Roland Kuhn

unread,
Oct 20, 2017, 1:38:09 PM10/20/17
to 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.
Reply all
Reply to author
Forward
0 new messages