Skip to content

Commit e024bd8

Browse files
authored
feat(native): Add idleTimeout configuration for http2 server (#26462)
``` == NO RELEASE NOTE == ```
1 parent a252163 commit e024bd8

File tree

3 files changed

+14
-1
lines changed

3 files changed

+14
-1
lines changed

presto-native-execution/presto_cpp/main/common/Configs.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ SystemConfig::SystemConfig() {
153153
NUM_PROP(kHttpServerHttp2InitialReceiveWindow, 1 << 20),
154154
NUM_PROP(kHttpServerHttp2ReceiveStreamWindowSize, 1 << 20),
155155
NUM_PROP(kHttpServerHttp2ReceiveSessionWindowSize, 10 * (1 << 20)),
156+
NUM_PROP(kHttpServerIdleTimeoutMs, 60'000),
156157
STR_PROP(
157158
kHttpsSupportedCiphers,
158159
"ECDHE-ECDSA-AES256-GCM-SHA384,AES256-GCM-SHA384"),
@@ -318,6 +319,10 @@ uint32_t SystemConfig::httpServerHttp2ReceiveSessionWindowSize() const {
318319
.value();
319320
}
320321

322+
uint32_t SystemConfig::httpServerIdleTimeoutMs() const {
323+
return optionalProperty<uint32_t>(kHttpServerIdleTimeoutMs).value();
324+
}
325+
321326
std::string SystemConfig::httpsSupportedCiphers() const {
322327
return optionalProperty(kHttpsSupportedCiphers).value();
323328
}

presto-native-execution/presto_cpp/main/common/Configs.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,11 @@ class SystemConfig : public ConfigBase {
218218
/// HTTP/2 receive session window size in bytes (default 10MB).
219219
static constexpr std::string_view kHttpServerHttp2ReceiveSessionWindowSize{
220220
"http-server.http2.receive-session-window-size"};
221+
222+
/// HTTP server idle timeout in milliseconds
223+
static constexpr std::string_view kHttpServerIdleTimeoutMs{
224+
"http-server.idle-timeout-ms"};
225+
221226
/// List of comma separated ciphers the client can use.
222227
///
223228
/// NOTE: the client needs to have at least one cipher shared with server
@@ -821,6 +826,8 @@ class SystemConfig : public ConfigBase {
821826

822827
uint32_t httpServerHttp2ReceiveSessionWindowSize() const;
823828

829+
uint32_t httpServerIdleTimeoutMs() const;
830+
824831
/// A list of ciphers (comma separated) that are supported by
825832
/// server and client. Note Java and folly::SSLContext use different names to
826833
/// refer to the same cipher. For e.g. TLS_RSA_WITH_AES_256_GCM_SHA384 in Java

presto-native-execution/presto_cpp/main/http/HttpServer.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,8 @@ void HttpServer::start(
273273
std::function<void(proxygen::HTTPServer* /*server*/)> onSuccess,
274274
std::function<void(std::exception_ptr)> onError) {
275275
proxygen::HTTPServerOptions options;
276-
options.idleTimeout = std::chrono::milliseconds(60'000);
276+
options.idleTimeout = std::chrono::milliseconds(
277+
SystemConfig::instance()->httpServerIdleTimeoutMs());
277278
options.enableContentCompression = false;
278279

279280
proxygen::RequestHandlerChain handlerFactories;

0 commit comments

Comments
 (0)