summaryrefslogtreecommitdiffstats
path: root/vespaclient-container-plugin
diff options
context:
space:
mode:
authorHaakon Dybdahl <dybdahl@yahoo-inc.com>2017-01-26 08:35:10 +0100
committerHaakon Dybdahl <dybdahl@yahoo-inc.com>2017-01-26 08:52:05 +0100
commite24984c67d03d9fc4de679ddecc769684aff697b (patch)
tree4c32c489ada17411f88ea1618d1f8bb1afaf3992 /vespaclient-container-plugin
parent5014f2a78843fe25490df4b5bbaab8478275113e (diff)
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.java14
-rw-r--r--vespaclient-container-plugin/src/main/java/com/yahoo/vespa/http/server/FeedHandlerV3.java8
2 files changed, 15 insertions, 7 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 f6a6ed05e57..86468806d99 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;
@@ -53,16 +54,23 @@ public class RestApi extends LoggingRequestHandler {
private final OperationHandler operationHandler;
private SingleDocumentParser singleDocumentParser;
private ObjectMapper mapper = new ObjectMapper();
- private AtomicInteger threadsAvailableForApi = new AtomicInteger(200 /*max concurrent requests */);
+ private 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);
}
}