2

I just came across Akka.net today, and it looks like a perfect fit for one of my projects. But I need kind of a zero-config cluster, where users just start up the app on multiple machines on their (local) network and they automatically form a cluster. I'm not sure if this is possible with Akka.net, as I wouldn't have seed nodes to put into the configuration file.

I guess, if there's an option to set seed nodes programmatically, I can broadcast to find other nodes, but it wouldn't really be guaranteed that all nodes start with the same set of seed nodes. Is it possible to start node A with seed node B, and node C with seed node A and so on?

Haukinger
  • 10,420
  • 2
  • 15
  • 28

1 Answers1

3

You can set cluster node from code using Cluster plugin i.e. Cluster.Get(Context.System).Join(nodeAddress). If you want to initialize a current node as a cluster seed, just order it to join to itself (cluster.SelfAddress).

In order to join any other node to a cluster, you just need to know address of at least one node, that is part of the cluster already. So yes you can join A ⇒ B and C ⇒ A in scenario descibed by you.

Bartosz Sypytkowski
  • 7,463
  • 19
  • 36
  • I'm starting all my nodes without seed-nodes, then broadcast and `Join` to the first one who replies. But they don't seem to be able to form a cluster, they all say "No seed-nodes configured, manual cluster join required", and `Join` doesn't seem to do anything, i.e. messages aren't routed to other nodes. But if I kill one node, the others report errors that a connection was refused. – Haukinger Oct 06 '16 at 18:25
  • This sounds like you're not addressing actors on other nodes correctly. Maybe [this](http://stackoverflow.com/questions/35634127/akka-net-access-remote-actors-in-cluster) StackOverflow issue will help you. – Bartosz Sypytkowski Oct 06 '16 at 19:25
  • Not sure, whether that'll solve my problem, for if I start _one_ of my nodes with a seed-node configured to point to itself and give it time to start up before starting the others, everything works fine. I'm running all nodes on one (dev-)machine (but with different ports, of course), can this cause a problem? – Haukinger Oct 07 '16 at 06:20
  • You need to have at least one node joining to itself and wait for that procedure to complete. Otherwise cluster won't be initialized. – Bartosz Sypytkowski Oct 07 '16 at 06:40
  • That's bad news, because I suppose I cannot do that on more than one node, otherwise I get multiple independent clusters? – Haukinger Oct 07 '16 at 08:57
  • Yes. You may need some index, where your nodes would fetch addresses of other nodes and eventually join to them or register themselves. This problem is known as service discovery and depending on the infrastructure you're using, there are some 3rd party tools for stuff like that (i.e. Azure Service Fabric, Consul, Etcd or Zookeeper). – Bartosz Sypytkowski Oct 07 '16 at 10:21
  • I've got a solution now, using WCF auto discovery, that seems to work. Thanks a lot for your help! – Haukinger Oct 12 '16 at 08:31