From b131a4fd3be8ab777ce3e1fa381123d741898676 Mon Sep 17 00:00:00 2001 From: Himanshu Gupta Date: Mon, 23 Mar 2015 21:46:27 -0500 Subject: [PATCH] adding router numMaxThread configuration for ProxyServlet HttpClient executor --- docs/content/Router.md | 3 +++ .../java/io/druid/guice/http/DruidHttpClientConfig.java | 9 +++++++++ .../java/io/druid/cli/RouterJettyServerInitializer.java | 6 +++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/content/Router.md b/docs/content/Router.md index dfc49159230..1cefbc3dd7d 100644 --- a/docs/content/Router.md +++ b/docs/content/Router.md @@ -56,6 +56,9 @@ druid.router.tierToBrokerMap={"hot":"druid:prod:broker-hot","_default_tier":"dru druid.router.http.numConnections=50 druid.router.http.readTimeout=PT5M +# Number of threads used by the router proxy http client +druid.router.http.numMaxThreads=100 + druid.server.http.numThreads=100 ``` diff --git a/server/src/main/java/io/druid/guice/http/DruidHttpClientConfig.java b/server/src/main/java/io/druid/guice/http/DruidHttpClientConfig.java index 3c350ee9307..9b37912cefc 100644 --- a/server/src/main/java/io/druid/guice/http/DruidHttpClientConfig.java +++ b/server/src/main/java/io/druid/guice/http/DruidHttpClientConfig.java @@ -35,6 +35,10 @@ public class DruidHttpClientConfig @JsonProperty private Period readTimeout = new Period("PT15M"); + @JsonProperty + @Min(1) + private int numMaxThreads = Math.max(10, (Runtime.getRuntime().availableProcessors() * 17) / 16 + 2) + 30; + public int getNumConnections() { return numConnections; @@ -44,4 +48,9 @@ public class DruidHttpClientConfig { return readTimeout == null ? null : readTimeout.toStandardDuration(); } + + public int getNumMaxThreads() + { + return numMaxThreads; + } } diff --git a/services/src/main/java/io/druid/cli/RouterJettyServerInitializer.java b/services/src/main/java/io/druid/cli/RouterJettyServerInitializer.java index 0301cc2da52..af96bc270d2 100644 --- a/services/src/main/java/io/druid/cli/RouterJettyServerInitializer.java +++ b/services/src/main/java/io/druid/cli/RouterJettyServerInitializer.java @@ -89,7 +89,11 @@ public class RouterJettyServerInitializer implements JettyServerInitializer requestLogger ); asyncQueryForwardingServlet.setTimeout(httpClientConfig.getReadTimeout().getMillis()); - root.addServlet(new ServletHolder(asyncQueryForwardingServlet), "/druid/v2/*"); + ServletHolder sh = new ServletHolder(asyncQueryForwardingServlet); + //NOTE: explicit maxThreads to workaround https://tickets.puppetlabs.com/browse/TK-152 + sh.setInitParameter("maxThreads", Integer.toString(httpClientConfig.getNumMaxThreads())); + + root.addServlet(sh, "/druid/v2/*"); JettyServerInitUtils.addExtensionFilters(root, injector); root.addFilter(JettyServerInitUtils.defaultAsyncGzipFilterHolder(), "/*", null); // Can't use '/*' here because of Guice conflicts with AsyncQueryForwardingServlet path