8
votes

Looking at the akka cluster documentation it appears that you have to know the server & port values of at least 1 "seed node" to join the cluster. The example application.conf clearly indicates that the developer needs to know "host1" and "host2" when writing the file:

akka.cluster.seed-nodes = [
  "akka.tcp://ClusterSystem@host1:2552",
  "akka.tcp://ClusterSystem@host2:2552"]

But, consider the possibility of registering each cluster node with a DNS load balancer. For example: it is possible to instantiate 10 nodes that are all registered with a load balancer behind the name "foobar.cluster.com" such that the load balancer will send each new connection to one of the 10 nodes round-robin style.

Could I then set the seed-node to "akka.tcp://[email protected]:2552"?

In other words, Is it possible to use dynamic, load balancing, names to join an akka cluster?

A priori there is one potential issue: a node may get itself as the seed node on the first try. One potential solution to this issue is putting the same seed node value multiple times in the conf file to get a high probability of eventually connecting to a different node:

akka.cluster.seed-nodes = [
  "akka.tcp://[email protected]:2552",
  "akka.tcp://[email protected]:2552",
  "akka.tcp://[email protected]:2552"]

But akka may just reduce all of those values to a single call since they are all exactly the same...

Thank you in advance for your consideration and response.

1

1 Answers

4
votes

It is possible, but you have to do the DNS resolution yourself, and then join the cluster programmatically. This is somewhat described here: http://doc.akka.io/docs/akka/current/scala/cluster-usage.html#Joining_to_Seed_Nodes

So you would first need your configuration file to contain akka.cluster.seed-nodes = [] in order to disable auto joining.

Then you would need to resolve foobar.cluster.com to get a list of actual nodes i.e., 01.foobar.cluster.com, 02.foobar.cluster.com, ...

You would use those to join the cluster: Cluster(system).joinSeedNodes(_list_of_nodes_with_port).

Finally, remember that when the hostname and port pair that Akka binds to will be different than the "logical" host name and port pair that is used to connect to the system from the outside. This requires special configuration