diff --git a/powerjob-remote/powerjob-remote-impl-http/src/main/java/tech/powerjob/remote/http/vertx/VertxInitializer.java b/powerjob-remote/powerjob-remote-impl-http/src/main/java/tech/powerjob/remote/http/vertx/VertxInitializer.java index 602f1df0..d74c0591 100644 --- a/powerjob-remote/powerjob-remote-impl-http/src/main/java/tech/powerjob/remote/http/vertx/VertxInitializer.java +++ b/powerjob-remote/powerjob-remote-impl-http/src/main/java/tech/powerjob/remote/http/vertx/VertxInitializer.java @@ -26,16 +26,22 @@ public class VertxInitializer { */ private static final int DEFAULT_KEEP_ALIVE_TIMEOUT = 75; - private static final int CONNECTION_TIMEOUT_MS = 2000; + private static final int CONNECTION_TIMEOUT_MS = 3000; + + private static final int SERVER_IDLE_TIMEOUT_S = 300; public static Vertx buildVertx() { - VertxOptions options = new VertxOptions(); + final int cpuCores = Runtime.getRuntime().availableProcessors(); + VertxOptions options = new VertxOptions() + .setWorkerPoolSize(Math.max(16, 2 * cpuCores)) + .setInternalBlockingPoolSize(Math.max(32, 4 * cpuCores)); log.info("[PowerJob-Vertx] use vertx options: {}", options); return Vertx.vertx(options); } public static HttpServer buildHttpServer(Vertx vertx) { - HttpServerOptions httpServerOptions = new HttpServerOptions(); + HttpServerOptions httpServerOptions = new HttpServerOptions() + .setIdleTimeout(SERVER_IDLE_TIMEOUT_S); tryEnableCompression(httpServerOptions); log.info("[PowerJob-Vertx] use HttpServerOptions: {}", httpServerOptions.toJson()); return vertx.createHttpServer(httpServerOptions);