Faster access to started shards count of the index in each node #53559
Labels
:Distributed Coordination/Allocation
All issues relating to the decision making around placing a shard (both master logic & on the nodes)
ES_VERSION: 7.6.0
JVM version : JDK1.8.0_112
OS version : linux
Description of the problem including expected versus actual behavior:
As it's known, Updating ClusterState on master may cost too much time, which is not good for cluster. During the updating ClusterState, ShardsLimitAllocationDecider deciders iterate through all the shards on a node to find STARTED ones belonging to the index when
cluster.routing.allocation.total_shards_per_node
> 0, Which will cost too much time.In out product, There are 39 nodes and 2,000 indices, 50,000 shards, but the time to update cluster state reach at 3.4min, It's intolerable.
To find out why it cost so much time on updating cluste state, I get the thread stack about updateTask, such that:
I try several times and get the same thread stack, it seems that ShardsLimitAllocationDecider.doDecide will cost too much time, the related code:
It will iterate 50000*50000/39 = 64,000,000 times, which will cost too much time.
There is room for optimization to avoid iterating the node:
1.If indexShardLimit=-1 and clusterShardLimit>0, we need't to count
indexShardCount
andnodeShardCount
by iterating,nodeShardCount = node.size() - node.numberOfShardsWithState(ShardRoutingState.RELOCATING)
, indexShardCount is useless.2. If we could count the started shards of each index in each node in RoutingNode to avoid the iteration?
The text was updated successfully, but these errors were encountered: