Anand
Anand

Reputation: 551

Is it okay to create a Seed Node which does not host any shard or proxyShard

I have a 3 node cluster with

1 S1 - Seed Node 2 S2 - A node that hosts a shard SRD (which has S1 as seed node in config) 3 S3 - A node that hosts the proxy shard of the shard hosted in S2 (which has S1 as seed node in config)

Here S1 just creates the actorsystem, and does nothing else

When I Start the cluster (S1 first, then S2 and S3) and When S3 tries to send a message to the shard SRD(using the proxyshard actor ref), it complains:

WARN  akka.cluster.sharding.ShardRegion - Trying to register to coordinator at [Some(ActorSelection[Anchor(akka.tcp://ngage-akka-seed-cluster@akka-0.akka-svc.default.svc.cluster.local:2551/),
Path(/system/sharding/CallEntityCoordinator/singleton/coordinator)])], but no acknowledgement. Total [1] buffered messages.

Here - akka-0.akka-svc.default.svc.cluster.local is the Seed node!!!, why is it contacting Seed node (which does not have any shard) instead of S2 ?

Upvotes: 1

Views: 417

Answers (1)

Bartosz Sypytkowski
Bartosz Sypytkowski

Reputation: 7542

By default akka-cluster-sharding shards and shard proxies will automatically assume, that corresponding regions are living on all nodes in the cluster. You can however apply constraint on that - both shard region and proxy allows you to specify the cluster role, i.e.:

# HOCON config
akka.cluster.roles = [ "sharding" ]
akka.cluster.sharding.role = "sharding"

You can also specify it manually:

// shard region - current cluster node must have that role
ClusterSharding(system).start(
    typeName = "Counter",
    entityProps = Props[Counter],
    settings = ClusterShardingSettings(system).withRole("sharding"),
    extractEntityId = extractEntityId,
    extractShardId = extractShardId)

// shard region proxy - current cluster node doesn't need to have that role
ClusterSharding(system).startProxy(
    typeName = "Counter",
    role = "sharding",
    dataCenter = Some("B"),
    extractEntityId = extractEntityId,
    extractShardId = extractShardId)

If it has been configured, cluster sharding will look up for shard regions only on cluster nodes with that role specified. You can use this mechanic to exclude seed nodes from the list of the nodes, cluster sharding will try to contact with.

Upvotes: 3

Related Questions