How to correctly determine the weight of a node

Hey there,

I was wondering the same thing, and went on a little trip into the rabbit hole.

There you have the code for the WeightFunction class that compute the weight of each nodes.

And as you can see the weight function does the computation on 4 characteristics of a node:

  • ShardsLoad = Number of shard on the node - Avg number of shards per node in the cluster
  • IndexLoad = Number of shard for a given index - Avg number of shards for a given index in the cluster
  • WriteLoad = Write load on a node - Avg write load
  • DiskLoad = Actual disk usage - Avg disk usage in the cluster

All of those are then multiplied by their respective settings and divided by the sum of all settings.

SumSettings = cluster.routing.allocation.balance.shard + cluster.routing.allocation.balance.index + cluster.routing.allocation.balance.disk_usage + cluster.routing.allocation.balance.write_load

So in the end you have:

Weight = ShardsLoad * cluster.routing.allocation.balance.shard / SumSettings
+ IndexLoad * cluster.routing.allocation.balance.index / SumSettings
+ WriteLoad * cluster.routing.allocation.balance.write_load / SumSettings
+ DiskLoad * cluster.routing.allocation.balance.disk_usage / SumSettings

1 Like