Dominick
Dominick

Reputation: 476

Nested, Remote, Round-Robin Pool in Akka.NET

I have started working with Akka.NET and was able an application with did self deployment on a remote system with multiple instances (deployment using a round-robin pool router with 5 instances). However, now I want to be able to link multiple servers together. Currently I have this working:

Local Actor --> Remote Actor --> 5 instances

However I am trying to do something like this:

           /--->Remote Actor #1 (server1.domain.com) --> 5 instances
Main Actor< --->Remote Actor #2 (server2.domain.com) --> 5 instances
           \--->Remote Actor #3 (server3.domain.com) --> 5 instances

When Main Actor has a message that needs to be processed, it sends it to Remote Actor 1, 2, OR 3 in a round-robin fashion. The remote actor who receives the message then sends it to one of the instances, also in a round-robin fashion.

From what I've read, it seems like I need to implement clustering. However, I could not tell from the documentation I found about how to implement it with this kind of nested round-robin processing. It sounded more like a decentralized network where a message from Main Actor would be passed to Remote Actor 1, 2, AND 3 which is definitely not what I would like.

Is there any way with the standard Akka.NET NuGets to implement this or do I need to implement the my own round-robin code in Main Actor to send a message to each of the Remote Actor's individual and then let them do their own, standard round-robin.

Any help or suggestion would be greatly appreciated as I am relatively new to using this library. Thank you in advanced.

Upvotes: 0

Views: 262

Answers (2)

Aaronontheweb
Aaronontheweb

Reputation: 8414

I think @Mestical's response is what you want, but just to clarify:

  1. You can have the Main Actor use a Group round robin router to send messages to the remote actor's on your sub-domains;
  2. Each of those remote actors can implement a local Pool round robin router to load-balance work locally between N identical actors.

Group routers use the ActorPath to message actors created by someone else, whereas Pool routers create the N identical child actors. The former is generally used for message distribution between ActorSystems over Akka.Cluster / Akka.Remote whereas the latter is primarily used to parallelize work.

What Akka.Cluster makes easier in your situation is the possibility for your Group router to dynamically discover new nodes at run-time (or old nodes removed when they're terminated,) whereas Akka.Remote requires that information to be baked into configuration at startup. Akka.Cluster is just more dynamic, in other words.

Upvotes: 0

Mestical
Mestical

Reputation: 56

you don't need to create your own round-robin code. You are almost there, you just need a little tweaking of your code.

Have you gone through this? What you need is to configure the hostnames.

I created this to better explain this to you

  1. From Main Actor/Router you can remotely deploy routers
  2. You can go through these two pages (Router with remote actors and How to use HOCON to configure your routers) for better understanding.

Please let me know if this is not clear to you!

Upvotes: 1

Related Questions