Skip to content

armgit / solr

Public Imported from GitHub
0

Apache Solr open-source search software

HttpJettySolrClient: use fewer threads (#4668)

David Smiley53800021a90b
diff --git a/changelog/unreleased/PR#4668-JettyClientFewerThreads.yml b/changelog/unreleased/PR#4668-JettyClientFewerThreads.yml
new file mode 100644
index 00000000000..826c5f464ac
--- /dev/null
+++ b/changelog/unreleased/PR#4668-JettyClientFewerThreads.yml
@@ -0,0 +1,9 @@
+title: >
+ HttpJettySolrClient defaults would often create 32 threads, likely under-utilizing them. and it would cap threads to 256.
+ Now it does neither by default but Executor customization (and other saturation controls) remain.
+type: changed
+authors:
+ - name: David Smiley
+links:
+ - name: PR#4668
+ url: https://github.com/apache/solr/pull/4668
diff --git a/solr/solrj-jetty/src/java/org/apache/solr/client/solrj/jetty/HttpJettySolrClient.java b/solr/solrj-jetty/src/java/org/apache/solr/client/solrj/jetty/HttpJettySolrClient.java
index 0e5c885feba..e561dc4d056 100644
--- a/solr/solrj-jetty/src/java/org/apache/solr/client/solrj/jetty/HttpJettySolrClient.java
+++ b/solr/solrj-jetty/src/java/org/apache/solr/client/solrj/jetty/HttpJettySolrClient.java
@@ -83,7 +83,6 @@ import org.eclipse.jetty.http.MultiPart;
import org.eclipse.jetty.http2.client.HTTP2Client;
import org.eclipse.jetty.http2.client.transport.HttpClientTransportOverHTTP2;
import org.eclipse.jetty.io.ClientConnector;
-import org.eclipse.jetty.util.BlockingArrayQueue;
import org.eclipse.jetty.util.ssl.KeyStoreScanner;
import org.eclipse.jetty.util.ssl.SslContextFactory;
import org.slf4j.Logger;
@@ -220,10 +219,7 @@ public class HttpJettySolrClient extends HttpSolrClient {
private HttpClient createHttpClient(Builder builder) {
executor = builder.getExecutor();
if (executor == null) {
- BlockingArrayQueue<Runnable> queue = BlockingArrayQueue.newInstance(256, Integer.MAX_VALUE);
- this.executor =
- new ExecutorUtil.MDCAwareThreadPoolExecutor(
- 32, 256, 60, TimeUnit.SECONDS, queue, new SolrNamedThreadFactory("h2sc"));
+ this.executor = ExecutorUtil.newMDCAwareCachedThreadPool(new SolrNamedThreadFactory("h2sc"));
shutdownExecutor = true;
} else {
shutdownExecutor = false;