Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Akka Cluster Joining with DNS Load Balancing

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.

like image 494
Ramón J Romero y Vigil Avatar asked Mar 24 '17 12:03

Ramón J Romero y Vigil


People also ask

How do I join an Akka cluster without a seed node?

akka.cluster.shutdown-after-unsuccessful-join-seed-nodes = 20s akka.coordinated-shutdown.exit-jvm = on If you don’t configure seed nodes or use one of the join seed node functions, you need to join the cluster manually by using JMX or HTTP. You can join to any node in the cluster. It does not have to be configured as a seed node.

Why Akka cluster/management use a headless service?

For Akka Cluster / Management use a headless service. This allows the solution to not be coupled to k8s as well as there is no use case for load balancing across management/remoting ports. Set endpoints to be published before readiness checks pass as these endpoints are required to bootstrap the Cluster and make the application ready.

Can Akka cluster be used across multiple data centers?

Akka Cluster can be used across multiple data centers, availability zones or regions, so that one Cluster can span multiple data centers and still be tolerant to network partitions. See Cluster Multi-DC. Communication from an actor system that is not part of the cluster to actors running somewhere in the cluster.

What is the minimum configuration required for the Akka actor?

And the minimum configuration required is to set a host/port for remoting and the akka.actor.provider = "cluster". The actor registers itself as subscriber of certain cluster events. It receives events corresponding to the current state of the cluster when the subscription starts and then it receives events for changes that happen in the cluster.


1 Answers

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

like image 120
Frederic A. Avatar answered Oct 21 '22 21:10

Frederic A.