Skip to content

Commit 238198e

Browse files
committed
Add ability to configure GRPC max connection age and max connection age grace
1 parent 4b34a48 commit 238198e

File tree

3 files changed

+40
-0
lines changed

3 files changed

+40
-0
lines changed

src/command_line_parser.cc

+20
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,8 @@ enum TritonOptionId {
310310
OPTION_GRPC_ARG_HTTP2_MIN_RECV_PING_INTERVAL_WITHOUT_DATA_MS,
311311
OPTION_GRPC_ARG_HTTP2_MAX_PING_STRIKES,
312312
OPTION_GRPC_RESTRICTED_PROTOCOL,
313+
OPTION_GRPC_ARG_MAX_CONNECTION_AGE_MS,
314+
OPTION_GRPC_ARG_MAX_CONNECTION_AGE_GRACE_MS,
313315
#endif // TRITON_ENABLE_GRPC
314316
#if defined(TRITON_ENABLE_SAGEMAKER)
315317
OPTION_ALLOW_SAGEMAKER,
@@ -568,6 +570,16 @@ TritonParser::SetupOptions()
568570
"Maximum number of bad pings that the server will tolerate before "
569571
"sending an HTTP2 GOAWAY frame and closing the transport. Setting it to "
570572
"0 allows the server to accept any number of bad pings. Default is 2."});
573+
grpc_options_.push_back(
574+
{OPTION_GRPC_ARG_MAX_CONNECTION_AGE_MS, "grpc-max-connection-age",
575+
Option::ArgInt,
576+
"Maximum time that a channel may exist in milliseconds. "
577+
"Default is INT_MAX (infinite)."});
578+
grpc_options_.push_back(
579+
{OPTION_GRPC_ARG_MAX_CONNECTION_AGE_GRACE_MS, "grpc-max-connection-age-grace",
580+
Option::ArgInt,
581+
"Grace period after the channel reaches its max age. "
582+
"Default is INT_MAX (infinite)."});
571583
grpc_options_.push_back(
572584
{OPTION_GRPC_RESTRICTED_PROTOCOL, "grpc-restricted-protocol",
573585
"<string>:<string>=<string>",
@@ -1436,6 +1448,14 @@ TritonParser::Parse(int argc, char** argv)
14361448
lgrpc_options.keep_alive_.http2_max_ping_strikes_ =
14371449
ParseOption<int>(optarg);
14381450
break;
1451+
case OPTION_GRPC_ARG_MAX_CONNECTION_AGE_MS:
1452+
lgrpc_options.keep_alive_.max_connection_age_ms_ =
1453+
ParseOption<int>(optarg);
1454+
break;
1455+
case OPTION_GRPC_ARG_MAX_CONNECTION_AGE_GRACE_MS:
1456+
lgrpc_options.keep_alive_.max_connection_age_grace_ms_ =
1457+
ParseOption<int>(optarg);
1458+
break;
14391459
case OPTION_GRPC_RESTRICTED_PROTOCOL: {
14401460
ParseRestrictedFeatureOption(
14411461
optarg, long_options[option_index].name,

src/grpc/grpc_server.cc

+17
Original file line numberDiff line numberDiff line change
@@ -2366,6 +2366,12 @@ Server::Server(
23662366
builder_.AddChannelArgument(
23672367
GRPC_ARG_HTTP2_MAX_PING_STRIKES,
23682368
keepalive_options.http2_max_ping_strikes_);
2369+
builder_.AddChannelArgument(
2370+
GRPC_ARG_MAX_CONNECTION_AGE_MS,
2371+
keepalive_options.max_connection_age_ms_);
2372+
builder_.AddChannelArgument(
2373+
GRPC_ARG_MAX_CONNECTION_AGE_GRACE_MS,
2374+
keepalive_options.max_connection_age_grace_ms_);
23692375

23702376
std::vector<std::string> headers{"GRPC KeepAlive Option", "Value"};
23712377
triton::common::TablePrinter table_printer(headers);
@@ -2399,6 +2405,17 @@ Server::Server(
23992405
"http2_max_ping_strikes",
24002406
std::to_string(keepalive_options.http2_max_ping_strikes_)};
24012407
table_printer.InsertRow(row);
2408+
2409+
row = {
2410+
"max_connection_age_ms",
2411+
std::to_string(
2412+
keepalive_options.max_connection_age_ms_)};
2413+
table_printer.InsertRow(row);
2414+
2415+
row = {
2416+
"max_connection_age_grace_ms",
2417+
std::to_string(keepalive_options.max_connection_age_grace_ms_)};
2418+
table_printer.InsertRow(row);
24022419
LOG_VERBOSE(1) << table_printer.PrintTable();
24032420
}
24042421

src/grpc/grpc_server.h

+3
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,16 @@ struct SslOptions {
6666
};
6767

6868
// GRPC KeepAlive: https://grpc.github.io/grpc/cpp/md_doc_keepalive.html
69+
// https://grpc.io/docs/guides/keepalive/
6970
struct KeepAliveOptions {
7071
int keepalive_time_ms_{7200000};
7172
int keepalive_timeout_ms_{20000};
7273
bool keepalive_permit_without_calls_{false};
7374
int http2_max_pings_without_data_{2};
7475
int http2_min_recv_ping_interval_without_data_ms_{300000};
7576
int http2_max_ping_strikes_{2};
77+
int max_connection_age_ms_{INT_MAX};
78+
int max_connection_age_grace_ms_{INT_MAX};
7679
};
7780

7881
struct Options {

0 commit comments

Comments
 (0)