summaryrefslogtreecommitdiffstats
path: root/vespaclient-container-plugin
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2017-01-26 14:31:15 +0100
committerGitHub <noreply@github.com>2017-01-26 14:31:15 +0100
commit7c4f0c4cd53d142444e40d66c436da989f263bce (patch)
tree18dc4a48fdf5283e2ddd8cc0072fa16aba182899 /vespaclient-container-plugin
parent8c19df88fe4d16fe6f8b74394ec29847c0269a48 (diff)
parentb657a7f6750a95af69f777c3fc6de0967875ebe8 (diff)
Merge pull request #1608 from yahoo/dybdahl/threads
Make document API use max 40% of threads, and feeding use max 40%.
Diffstat (limited to 'vespaclient-container-plugin')
-rw-r--r--vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/RestApi.java16
-rw-r--r--vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/FeedHandlerV3.java8
2 files changed, 16 insertions, 8 deletions
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/RestApi.java b/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/RestApi.java
index 18628af3eca..80769909b9f 100644
--- a/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/RestApi.java
+++ b/vespaclient-container-plugin/src/main/java/com/yahoo/document/restapi/resource/RestApi.java
@@ -6,6 +6,7 @@ import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.inject.Inject;
import com.fasterxml.jackson.databind.node.ObjectNode;
+import com.yahoo.container.handler.ThreadpoolConfig;
import com.yahoo.container.jdisc.HttpRequest;
import com.yahoo.container.jdisc.HttpResponse;
import com.yahoo.container.jdisc.LoggingRequestHandler;
@@ -52,17 +53,24 @@ public class RestApi extends LoggingRequestHandler {
private static final String APPLICATION_JSON = "application/json";
private final OperationHandler operationHandler;
private SingleDocumentParser singleDocumentParser;
- private ObjectMapper mapper = new ObjectMapper();
- private AtomicInteger threadsAvailableForApi = new AtomicInteger(200 /*max concurrent requests */);
+ private final ObjectMapper mapper = new ObjectMapper();
+ private final AtomicInteger threadsAvailableForApi;
@Inject
public RestApi(Executor executor, AccessLog accessLog, DocumentmanagerConfig documentManagerConfig,
- LoadTypeConfig loadTypeConfig) {
+ LoadTypeConfig loadTypeConfig, ThreadpoolConfig threadpoolConfig) {
super(executor, accessLog);
MessageBusParams params = new MessageBusParams(new LoadTypeSet(loadTypeConfig));
params.setDocumentmanagerConfig(documentManagerConfig);
this.operationHandler = new OperationHandlerImpl(new MessageBusDocumentAccess(params));
this.singleDocumentParser = new SingleDocumentParser(new DocumentTypeManager(documentManagerConfig));
+ // 40% of the threads can be blocked before we deny requests.
+ if (threadpoolConfig != null) {
+ threadsAvailableForApi = new AtomicInteger(Math.max((int) (0.4 * threadpoolConfig.maxthreads()), 1));
+ } else {
+ log.warning("No config for threadpool, using 200 for max blocking threads for document rest API.");
+ threadsAvailableForApi = new AtomicInteger(200);
+ }
}
// For testing and development
@@ -73,7 +81,7 @@ public class RestApi extends LoggingRequestHandler {
int threadsAvailable) {
super(executor, accessLog);
this.operationHandler = operationHandler;
- this.threadsAvailableForApi.set(threadsAvailable);
+ this.threadsAvailableForApi = new AtomicInteger(threadsAvailable);
}
@Override
diff --git a/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/FeedHandlerV3.java b/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/FeedHandlerV3.java
index 669e5a22ae9..72fe87ad9b6 100644
--- a/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/FeedHandlerV3.java
+++ b/vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/FeedHandlerV3.java
@@ -61,12 +61,12 @@ public class FeedHandlerV3 extends LoggingRequestHandler {
cron = new ScheduledThreadPoolExecutor(1, ThreadFactoryFactory.getThreadFactory("feedhandlerv3.cron"));
cron.scheduleWithFixedDelay(this::removeOldClients, 16, 11, TimeUnit.MINUTES);
this.metric = metric;
- // Half of the threads can be blocking on feeding before we deny requests.
+ // 40% of the threads can be blocking on feeding before we deny requests.
if (threadpoolConfig != null) {
- threadsAvailableForFeeding = new AtomicInteger(threadpoolConfig.maxthreads() / 2);
+ threadsAvailableForFeeding = new AtomicInteger(Math.max((int) (0.4 * threadpoolConfig.maxthreads()), 1));
} else {
- log.warning("No config for threadpool, using 250 for max blocking threads for feeding.");
- threadsAvailableForFeeding = new AtomicInteger(250);
+ log.warning("No config for threadpool, using 200 for max blocking threads for feeding.");
+ threadsAvailableForFeeding = new AtomicInteger(200);
}
}