Skip to content

Commit 6995190

Browse files
Add a comment to computeOptimalNumberOfShards
1 parent 9bcd595 commit 6995190

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

server/src/main/java/org/elasticsearch/action/datastreams/autosharding/DataStreamAutoShardingService.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,17 @@ private AutoShardingResult getDecreaseShardsResult(
322322

323323
// Visible for testing
324324
static long computeOptimalNumberOfShards(int minNumberWriteThreads, int maxNumberWriteThreads, double indexingLoad) {
325+
/*
326+
* Define:
327+
* - shardsByMaxThreads = number of shards required to ensure no more than 50% utilization with max number of threads per shard
328+
* - shardsByMaxThreads = number of shards required to ensure no more than 50% utilization with min number of threads per shard
329+
* Note that shardsByMaxThreads <= shardsByMinThreads.
330+
* This returns:
331+
* - shardsByMaxThreads if shardsByMaxThreads > 3
332+
* - 3 if shardsByMaxThreads <= 3 and shardsByMinThreads > 3
333+
* - shardsByMinThreads if 0 < shardsByMinThreads <= 3
334+
* - 1 if shardsByMinThreads == 0
335+
*/
325336
return Math.max(
326337
Math.max(
327338
Math.min(roundUp(indexingLoad / (minNumberWriteThreads / 2.0)), 3),

0 commit comments

Comments
 (0)