Skip to content

Commit 23ba7a0

Browse files
authored
Allow configuring GRPC max connection age and max connection age grace (#6639)
* Add ability to configure GRPC max connection age and max connection age grace * Allow pass GRPC connection age args when they are set from command ---------- Co-authored-by: Katherine Yang <[email protected]>
1 parent 2df7b25 commit 23ba7a0

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-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 undefined."});
578+
grpc_options_.push_back(
579+
{OPTION_GRPC_ARG_MAX_CONNECTION_AGE_GRACE_MS,
580+
"grpc-max-connection-age-grace", Option::ArgInt,
581+
"Grace period after the channel reaches its max age. "
582+
"Default is undefined."});
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

+24
Original file line numberDiff line numberDiff line change
@@ -2366,6 +2366,16 @@ Server::Server(
23662366
builder_.AddChannelArgument(
23672367
GRPC_ARG_HTTP2_MAX_PING_STRIKES,
23682368
keepalive_options.http2_max_ping_strikes_);
2369+
if (keepalive_options.max_connection_age_ms_ != 0) {
2370+
builder_.AddChannelArgument(
2371+
GRPC_ARG_MAX_CONNECTION_AGE_MS,
2372+
keepalive_options.max_connection_age_ms_);
2373+
}
2374+
if (keepalive_options.max_connection_age_grace_ms_ != 0) {
2375+
builder_.AddChannelArgument(
2376+
GRPC_ARG_MAX_CONNECTION_AGE_GRACE_MS,
2377+
keepalive_options.max_connection_age_grace_ms_);
2378+
}
23692379

23702380
std::vector<std::string> headers{"GRPC KeepAlive Option", "Value"};
23712381
triton::common::TablePrinter table_printer(headers);
@@ -2399,6 +2409,20 @@ Server::Server(
23992409
"http2_max_ping_strikes",
24002410
std::to_string(keepalive_options.http2_max_ping_strikes_)};
24012411
table_printer.InsertRow(row);
2412+
2413+
if (keepalive_options.max_connection_age_ms_ != 0) {
2414+
row = {
2415+
"max_connection_age_ms",
2416+
std::to_string(keepalive_options.max_connection_age_ms_)};
2417+
table_printer.InsertRow(row);
2418+
}
2419+
2420+
if (keepalive_options.max_connection_age_grace_ms_ != 0) {
2421+
row = {
2422+
"max_connection_age_grace_ms",
2423+
std::to_string(keepalive_options.max_connection_age_grace_ms_)};
2424+
table_printer.InsertRow(row);
2425+
}
24022426
LOG_VERBOSE(1) << table_printer.PrintTable();
24032427
}
24042428

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_{0};
78+
int max_connection_age_grace_ms_{0};
7679
};
7780

7881
struct Options {

0 commit comments

Comments
 (0)