From b08af9f776709423bcf37b70766d79cc4bdd96a4 Mon Sep 17 00:00:00 2001 From: Niketh Sabbineni Date: Thu, 17 Aug 2017 20:20:36 -0700 Subject: [PATCH] Add graceful shutdown timeout --- docs/content/configuration/broker.md | 1 + docs/content/configuration/historical.md | 1 + .../io/druid/server/initialization/ServerConfig.java | 10 ++++++++++ .../server/initialization/jetty/JettyServerModule.java | 1 + 4 files changed, 13 insertions(+) diff --git a/docs/content/configuration/broker.md b/docs/content/configuration/broker.md index 349d96442ffd..734267ededa7 100644 --- a/docs/content/configuration/broker.md +++ b/docs/content/configuration/broker.md @@ -39,6 +39,7 @@ Druid uses Jetty to serve HTTP requests. |`druid.server.http.maxIdleTime`|The Jetty max idle time for a connection.|PT5m| |`druid.server.http.defaultQueryTimeout`|Query timeout in millis, beyond which unfinished queries will be cancelled|300000| |`druid.server.http.maxScatterGatherBytes`|Maximum number of bytes gathered from data nodes such as historicals and realtime processes to execute a query. This is an advance configuration that allows to protect in case broker is under heavy load and not utilizing the data gathered in memory fast enough and leading to OOMs. This limit can be further reduced at query time using `maxScatterGatherBytes` in the context. Note that having large limit is not necessarily bad if broker is never under heavy concurrent load in which case data gathered is processed quickly and freeing up the memory used.|Long.MAX_VALUE| +|`druid.server.http.gracefulShutdownTimeout`|The maximum amount of time Jetty waits after receiving shutdown signal. After this timeout the threads will be forcefully shutdown. This allows any queries that are executing to complete.|PT5s| |`druid.broker.http.numConnections`|Size of connection pool for the Broker to connect to historical and real-time processes. If there are more queries than this number that all need to speak to the same node, then they will queue up.|20| |`druid.broker.http.compressionCodec`|Compression codec the Broker uses to communicate with historical and real-time processes. May be "gzip" or "identity".|gzip| |`druid.broker.http.readTimeout`|The timeout for data reads from historical and real-time processes.|PT15M| diff --git a/docs/content/configuration/historical.md b/docs/content/configuration/historical.md index 321408e78e16..1c8bff149bea 100644 --- a/docs/content/configuration/historical.md +++ b/docs/content/configuration/historical.md @@ -50,6 +50,7 @@ Druid uses Jetty to serve HTTP requests. |`druid.server.http.numThreads`|Number of threads for HTTP requests.|max(10, (Number of cores * 17) / 16 + 2) + 30| |`druid.server.http.maxIdleTime`|The Jetty max idle time for a connection.|PT5m| |`druid.server.http.defaultQueryTimeout`|Query timeout in millis, beyond which unfinished queries will be cancelled|300000| +|`druid.server.http.gracefulShutdownTimeout`|The maximum amount of time Jetty waits after receiving shutdown signal. After this timeout the threads will be forcefully shutdown. This allows any queries that are executing to complete.|PT5s| #### Processing diff --git a/server/src/main/java/io/druid/server/initialization/ServerConfig.java b/server/src/main/java/io/druid/server/initialization/ServerConfig.java index b299908bca4d..2d4a64ed179e 100644 --- a/server/src/main/java/io/druid/server/initialization/ServerConfig.java +++ b/server/src/main/java/io/druid/server/initialization/ServerConfig.java @@ -51,6 +51,10 @@ public class ServerConfig @JsonProperty private boolean tls = false; + @JsonProperty + @NotNull + private Period gracefulShutdownTimeout = new Period("PT5s"); + public int getNumThreads() { return numThreads; @@ -81,6 +85,11 @@ public boolean isTls() return tls; } + public Period getGracefulShutdownTimeout() + { + return gracefulShutdownTimeout; + } + @Override public String toString() { @@ -91,6 +100,7 @@ public String toString() ", maxScatterGatherBytes=" + maxScatterGatherBytes + ", plaintext=" + plaintext + ", tls=" + tls + + ", gracefulStopTimeout=" + gracefulShutdownTimeout + '}'; } } diff --git a/server/src/main/java/io/druid/server/initialization/jetty/JettyServerModule.java b/server/src/main/java/io/druid/server/initialization/jetty/JettyServerModule.java index 424eb21d322b..d26b8c096e47 100644 --- a/server/src/main/java/io/druid/server/initialization/jetty/JettyServerModule.java +++ b/server/src/main/java/io/druid/server/initialization/jetty/JettyServerModule.java @@ -227,6 +227,7 @@ static Server makeJettyServer(DruidNode node, ServerConfig config, TLSServerConf } server.setConnectors(connectors); + server.setStopTimeout(config.getGracefulShutdownTimeout().getMillis()); return server; }