We currently use a ConsistentHashingPool to provide sticky routes and throttling for a specific type of actor:
var hashRouter = new ConsistentHashingPool(_hashPoolSize).WithHashMapping(o =>
{
var command = o as IMyCommand;
if (command == null)
{
return null;
}
return command.Id;
});
We are in the process of adding clustering, and want to distribute the work for this actor across multiple nodes. I am using a ClusterRouterPool and providing my existing router as the local Pool constructor argument:
var clusterRouterPool = new ClusterRouterPool(hashRouter,
new ClusterRouterPoolSettings(1000, _hashPoolSize, true));
I'm not completely clear on what the constructor arguments of the ClusterRouterPoolSettings mean. The docs say:
nr-of-instances: this is the maximum number of total routees that this router will first deploy, and then route to.
max-nr-of-instances-per-node: the maximum number of routees that the Pool router will deploy onto a given cluster node.
Note that nr-of-instances defines total number of routees, but number of routees per node will not be exceeded, i.e. if you define nr-of-instances = 50 and max-nr-of-instances-per-node = 2, the router will deploy 2 routees per new node in the cluster, up to 25 nodes.
So if I set the number of instances to 1000 (as shown above), I would assume that the number that get deployed and routed to would not exceed the actual number of nodes in the cluster, is that correct?
Also, the max number of instances per node seems to conflict (or overlap) with the first constructor argument of ConsistentHashingPool. In the code above, I am setting the two values to be the same. Will it take the lesser of the two values?
Edit I was under the impression that the above code worked, and was just trying to understand if it was routing as I intended.
It turns out the above code doesn't work at all (deployed the wrong branch).