Skip to content

Commit 1c47301

Browse files
committed
Default max concurrent search req. to the avg shards size per index
We moved to 1 shard by default which caused some issues in how many concurrent shard requests we allow by default. For instance searching a 5 shard index on a single node will now be executed serially per shard while we want these cases to have a good concurrency out of the box. This change moves to defaults based on the avg. number of shards per index in the current search request to provide a good out of the box concurrency. Relates to elastic#30783 Closes elastic#30994
1 parent c352ff1 commit 1c47301

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

server/src/main/java/org/elasticsearch/action/search/TransportSearchAction.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -345,8 +345,13 @@ private void executeSearch(SearchTask task, SearchTimeProvider timeProvider, Sea
345345
* We try to set a default of max concurrent shard requests based on the node count but upper-bound it by 256 by default to keep
346346
* it sane. A single search request that fans out to lots of shards should not hit a cluster too hard while 256 is already a
347347
* lot.
348+
* Yet we are still trying to guarantee some concurrency ie. if you have an index size of N shards and you are searching a
349+
* single index on a single node we still search it concurrently.
348350
*/
349-
searchRequest.setMaxConcurrentShardRequests(Math.min(256, nodeCount));
351+
final int numShards = shardIterators.size();
352+
final int numIndices = remoteClusterIndices.size() + concreteIndices.length;
353+
assert numShards >= numIndices : "found schroedingers index numShards: " + numShards + " vs. numIndices: " + numIndices;
354+
searchRequest.setMaxConcurrentShardRequests(Math.min(256, nodeCount * (numShards / numIndices)));
350355
}
351356
boolean preFilterSearchShards = shouldPreFilterSearchShards(searchRequest, shardIterators);
352357
searchAsyncAction(task, searchRequest, shardIterators, timeProvider, connectionLookup, clusterState.version(),

0 commit comments

Comments
 (0)