Actor Selection for Remote Actors

380 views
Skip to first unread message

Paul Cleary

unread,
Aug 14, 2014, 9:17:54 AM8/14/14
to akka...@googlegroups.com
I am looking into using Akka Remoting, I am using akka 2.2.3.

I have to communicate with a bunch of remote actors.  I have a few questions about the best way to do this:

1. Do I simply send messages through an Actor Selection itself (there is a tell on actor selection)?  My concern is that this will not perform as well as using an Actor Ref directly.  Also, I am concerned about the behavior in the event that the remote actor is down, does the Actor Selection deliver the messages to dead letter until the remote actor comes back to life?

- if not -

2. Do I instead get an Actor Ref and use that actor ref to send messages (using the resolve method or Identify)?  My concern here is, what happens to the ActorRef if the remote actor dies?  Do we "need" to watch the remote actor and handle Terminated?

- are there other options? -


It would "seem" as though option 1 insulates me from having to care if the remote actor is there or not, because in my use case, I really don't care.

Option 2 seems like I have to do my own gymnastics to handle remote actor availability, but perhaps is better performing (or maybe is the recommended approach?)

Any help is greatly appreciated.

Thanks!

Patrik Nordwall

unread,
Aug 14, 2014, 11:53:53 AM8/14/14
to akka...@googlegroups.com
Hi Paul,

I think you have identified the two options and understood the differences and trade-offs. To make it clear, some comments inline...


On Thu, Aug 14, 2014 at 3:17 PM, Paul Cleary <pcle...@gmail.com> wrote:
I am looking into using Akka Remoting, I am using akka 2.2.3.

I have to communicate with a bunch of remote actors.  I have a few questions about the best way to do this:

1. Do I simply send messages through an Actor Selection itself (there is a tell on actor selection)?  My concern is that this will not perform as well as using an Actor Ref directly.

It is not as performant as with ActorRef, since it has to traverse the hierarchy of actors in the path. If you use remote sends the actor selection traversal will unlikely be the bottleneck, but you have to verify that for your specific usage. We optimized ActorSelection in 2.3.x, so it will be faster when you update to that version.
 
 Also, I am concerned about the behavior in the event that the remote actor is down, does the Actor Selection deliver the messages to dead letter until the remote actor comes back to life?

Yes, that is correct
 

- if not -

2. Do I instead get an Actor Ref and use that actor ref to send messages (using the resolve method or Identify)?  My concern here is, what happens to the ActorRef if the remote actor dies?  Do we "need" to watch the remote actor and handle Terminated?

Yes
 

- are there other options? -


It would "seem" as though option 1 insulates me from having to care if the remote actor is there or not, because in my use case, I really don't care.

Option 2 seems like I have to do my own gymnastics to handle remote actor availability, but perhaps is better performing (or maybe is the recommended approach?)

Right

Regards,
Patrik
 

Any help is greatly appreciated.

Thanks!

--
>>>>>>>>>> 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 http://groups.google.com/group/akka-user.
For more options, visit https://groups.google.com/d/optout.



--

Patrik Nordwall
Typesafe Reactive apps on the JVM
Twitter: @patriknw

Paul Cleary

unread,
Aug 15, 2014, 7:24:05 AM8/15/14
to akka...@googlegroups.com
Thanks Patrik!

Just one more question, what do you mean by "If you use remote sends the actor selection traversal will unlikely be the bottleneck"?

Patrik Nordwall

unread,
Aug 15, 2014, 8:47:51 AM8/15/14
to akka...@googlegroups.com
On Fri, Aug 15, 2014 at 1:24 PM, Paul Cleary <pcle...@gmail.com> wrote:
Thanks Patrik!

Just one more question, what do you mean by "If you use remote sends the actor selection traversal will unlikely be the bottleneck"?

I mean that the performance difference between ActorRef and ActorSelection might be small compared to the sending a message over the wire (network, serialization).

/Patrik
Reply all
Reply to author
Forward
0 new messages