From 95b0a6a2cf46de2f900cc08466d9697fbb2d4e5e Mon Sep 17 00:00:00 2001 From: Jason Tedor Date: Tue, 8 Mar 2016 08:34:46 -0500 Subject: [PATCH] Limit generic thread pool The generic thread pool was previously configured to be able to create an unlimited number of threads. The thinking is that tasks that are submitted to its work queue must execute and should not block waiting for a worker. However, in cases of heavy load, this can lead to an explosion in the number of threads; this can even lead to a feedback loop that exacerbates the problem. What is more, this can even bump into OS limits on the number of threads that can be created. This commit limits the number of threads in the generic thread pool to four times the bounded number of processors. Relates #17003 --- core/src/main/java/org/elasticsearch/threadpool/ThreadPool.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/src/main/java/org/elasticsearch/threadpool/ThreadPool.java b/core/src/main/java/org/elasticsearch/threadpool/ThreadPool.java index c7f4392e56a..8b6f1198705 100644 --- a/core/src/main/java/org/elasticsearch/threadpool/ThreadPool.java +++ b/core/src/main/java/org/elasticsearch/threadpool/ThreadPool.java @@ -222,7 +222,7 @@ public class ThreadPool extends AbstractComponent implements Closeable { int halfProcMaxAt5 = Math.min(((availableProcessors + 1) / 2), 5); int halfProcMaxAt10 = Math.min(((availableProcessors + 1) / 2), 10); Map defaultExecutorTypeSettings = new HashMap<>(); - add(defaultExecutorTypeSettings, new ExecutorSettingsBuilder(Names.GENERIC).keepAlive("30s")); + add(defaultExecutorTypeSettings, new ExecutorSettingsBuilder(Names.GENERIC).size(4 * availableProcessors).keepAlive("30s")); add(defaultExecutorTypeSettings, new ExecutorSettingsBuilder(Names.INDEX).size(availableProcessors).queueSize(200)); add(defaultExecutorTypeSettings, new ExecutorSettingsBuilder(Names.BULK).size(availableProcessors).queueSize(50)); add(defaultExecutorTypeSettings, new ExecutorSettingsBuilder(Names.GET).size(availableProcessors).queueSize(1000));