Skip to content

Commit

Permalink
Add default max connection lifetime config to gRPC servers (ava-labs#…
Browse files Browse the repository at this point in the history
  • Loading branch information
joshua-kim authored Jul 21, 2022
1 parent 0e045db commit de0a359
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions vms/rpcchainvm/grpcutils/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ const (
// of Timeout and if no activity is seen even after that the connection is
// closed. grpc-go default 20s
defaultServerKeepAliveTimeout = 20 * time.Second
// Duration for the maximum amount of time a http2 connection can exist
// before sending GOAWAY. Internally in gRPC a +-10% jitter is added to
// mitigate retry storms.
defaultServerMaxConnectionAge = 10 * time.Minute
// Grace period after max defaultServerMaxConnectionAge after
// which the http2 connection is closed. 1 second is the minimum possible
// value. Anything less will be internally overridden to 1s by grpc.
defaultServerMaxConnectionAgeGrace = 1 * time.Second

// Client:

Expand Down Expand Up @@ -79,8 +87,10 @@ var (
PermitWithoutStream: defaultPermitWithoutStream,
}),
grpc.KeepaliveParams(keepalive.ServerParameters{
Time: defaultServerKeepAliveInterval,
Timeout: defaultServerKeepAliveTimeout,
Time: defaultServerKeepAliveInterval,
Timeout: defaultServerKeepAliveTimeout,
MaxConnectionAge: defaultServerMaxConnectionAge,
MaxConnectionAgeGrace: defaultServerMaxConnectionAgeGrace,
}),
}
)
Expand Down

0 comments on commit de0a359

Please sign in to comment.