diff --git a/core/java8/proxy/src/main/java/org/apache/openwhisk/runtime/java/action/Proxy.java b/core/java8/proxy/src/main/java/org/apache/openwhisk/runtime/java/action/Proxy.java index 4c0dc21f..ad858ec7 100644 --- a/core/java8/proxy/src/main/java/org/apache/openwhisk/runtime/java/action/Proxy.java +++ b/core/java8/proxy/src/main/java/org/apache/openwhisk/runtime/java/action/Proxy.java @@ -30,6 +30,9 @@ import java.util.HashMap; import java.util.Map; import java.util.Set; +import java.util.concurrent.ArrayBlockingQueue; +import java.util.concurrent.ThreadPoolExecutor; +import java.util.concurrent.TimeUnit; import com.google.gson.JsonElement; import com.google.gson.JsonObject; @@ -48,7 +51,20 @@ public Proxy(int port) throws IOException { this.server.createContext("/init", new InitHandler()); this.server.createContext("/run", new RunHandler()); - this.server.setExecutor(null); // creates a default executor + + if (Boolean.parseBoolean(System.getenv("__OW_ALLOW_CONCURRENT"))) { + ThreadPoolExecutor executor = new ThreadPoolExecutor( + 10, // Core size. + 25, // Max size. + 10 * 60, // Idle timeout. + TimeUnit.SECONDS, + new ArrayBlockingQueue(30) + ); + executor.allowCoreThreadTimeOut(true); + this.server.setExecutor(executor); + } else { + this.server.setExecutor(null); // Default executor. + } } public void start() {