Skip to content

Commit 6baedcf

Browse files
authored
chore(native): Add window size configuration for http2 server (#26383)
## Description 1. Make these three parameters configurable ## Motivation and Context 1. no hardcoding Differential Revision: D85145751 ## Release Notes Please follow [release notes guidelines](https://github.com/prestodb/presto/wiki/Release-Notes-Guidelines) and fill in the release notes below. ``` == NO RELEASE NOTE == ```
1 parent 6d3b641 commit 6baedcf

File tree

3 files changed

+41
-4
lines changed

3 files changed

+41
-4
lines changed

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

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@ SystemConfig::SystemConfig() {
150150
NONE_PROP(kHttpServerHttpsPort),
151151
BOOL_PROP(kHttpServerHttpsEnabled, false),
152152
BOOL_PROP(kHttpServerHttp2Enabled, true),
153+
NUM_PROP(kHttpServerHttp2InitialReceiveWindow, 1 << 20),
154+
NUM_PROP(kHttpServerHttp2ReceiveStreamWindowSize, 1 << 20),
155+
NUM_PROP(kHttpServerHttp2ReceiveSessionWindowSize, 10 * (1 << 20)),
153156
STR_PROP(
154157
kHttpsSupportedCiphers,
155158
"ECDHE-ECDSA-AES256-GCM-SHA384,AES256-GCM-SHA384"),
@@ -299,6 +302,21 @@ bool SystemConfig::httpServerHttp2Enabled() const {
299302
return optionalProperty<bool>(kHttpServerHttp2Enabled).value();
300303
}
301304

305+
uint32_t SystemConfig::httpServerHttp2InitialReceiveWindow() const {
306+
return optionalProperty<uint32_t>(kHttpServerHttp2InitialReceiveWindow)
307+
.value();
308+
}
309+
310+
uint32_t SystemConfig::httpServerHttp2ReceiveStreamWindowSize() const {
311+
return optionalProperty<uint32_t>(kHttpServerHttp2ReceiveStreamWindowSize)
312+
.value();
313+
}
314+
315+
uint32_t SystemConfig::httpServerHttp2ReceiveSessionWindowSize() const {
316+
return optionalProperty<uint32_t>(kHttpServerHttp2ReceiveSessionWindowSize)
317+
.value();
318+
}
319+
302320
std::string SystemConfig::httpsSupportedCiphers() const {
303321
return optionalProperty(kHttpsSupportedCiphers).value();
304322
}

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

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,15 @@ class SystemConfig : public ConfigBase {
209209
"http-server.https.enabled"};
210210
static constexpr std::string_view kHttpServerHttp2Enabled{
211211
"http-server.http2.enabled"};
212+
/// HTTP/2 initial receive window size in bytes (default 1MB).
213+
static constexpr std::string_view kHttpServerHttp2InitialReceiveWindow{
214+
"http-server.http2.initial-receive-window"};
215+
/// HTTP/2 receive stream window size in bytes (default 1MB).
216+
static constexpr std::string_view kHttpServerHttp2ReceiveStreamWindowSize{
217+
"http-server.http2.receive-stream-window-size"};
218+
/// HTTP/2 receive session window size in bytes (default 10MB).
219+
static constexpr std::string_view kHttpServerHttp2ReceiveSessionWindowSize{
220+
"http-server.http2.receive-session-window-size"};
212221
/// List of comma separated ciphers the client can use.
213222
///
214223
/// NOTE: the client needs to have at least one cipher shared with server
@@ -802,6 +811,12 @@ class SystemConfig : public ConfigBase {
802811

803812
bool httpServerHttp2Enabled() const;
804813

814+
uint32_t httpServerHttp2InitialReceiveWindow() const;
815+
816+
uint32_t httpServerHttp2ReceiveStreamWindowSize() const;
817+
818+
uint32_t httpServerHttp2ReceiveSessionWindowSize() const;
819+
805820
/// A list of ciphers (comma separated) that are supported by
806821
/// server and client. Note Java and folly::SSLContext use different names to
807822
/// 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: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -288,10 +288,14 @@ void HttpServer::start(
288288
handlerFactories.addThen(std::move(handlerFactory_));
289289
options.handlerFactories = handlerFactories.build();
290290

291-
// Increase the default flow control to 1MB/10MB
292-
options.initialReceiveWindow = static_cast<uint32_t>(1 << 20);
293-
options.receiveStreamWindowSize = static_cast<uint32_t>(1 << 20);
294-
options.receiveSessionWindowSize = 10 * (1 << 20);
291+
// HTTP/2 flow control window sizes (configurable)
292+
auto systemConfig = SystemConfig::instance();
293+
options.initialReceiveWindow =
294+
systemConfig->httpServerHttp2InitialReceiveWindow();
295+
options.receiveStreamWindowSize =
296+
systemConfig->httpServerHttp2ReceiveStreamWindowSize();
297+
options.receiveSessionWindowSize =
298+
systemConfig->httpServerHttp2ReceiveSessionWindowSize();
295299
options.h2cEnabled = true;
296300

297301
server_ = std::make_unique<proxygen::HTTPServer>(std::move(options));

0 commit comments

Comments
 (0)