Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Max age grace #3065

Merged
merged 1 commit into from
Aug 15, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions go/vt/servenv/grpc_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ var (
// GRPCMaxConnectionAge is the maximum age of a client connection, before GoAway is sent.
// This is useful for L4 loadbalancing to ensure rebalancing after scaling.
GRPCMaxConnectionAge *time.Duration

// GRPCMaxConnectionAgeGrace is an additional grace period after GRPCMaxConnectionAge, after which
// connections are forcibly closed.
GRPCMaxConnectionAgeGrace *time.Duration
)

// isGRPCEnabled returns true if gRPC server is set
Expand Down Expand Up @@ -116,9 +120,13 @@ func createGRPCServer() {
}

if GRPCMaxConnectionAge != nil {
opts = append(opts, grpc.KeepaliveParams(keepalive.ServerParameters{
ka := keepalive.ServerParameters{
MaxConnectionAge: *GRPCMaxConnectionAge,
}))
}
if GRPCMaxConnectionAgeGrace != nil {
ka.MaxConnectionAgeGrace = *GRPCMaxConnectionAgeGrace
}
opts = append(opts, grpc.KeepaliveParams(ka))
}

GRPCServer = grpc.NewServer(opts...)
Expand Down Expand Up @@ -158,6 +166,7 @@ func RegisterGRPCFlags() {
GRPCMaxMessageSize = flag.Int("grpc_max_message_size", 4*1024*1024, "Maximum allowed RPC message size. Larger messages will be rejected by gRPC with the error 'exceeding the max size'.")
// Default is effectively infinity, as defined in grpc.
GRPCMaxConnectionAge = flag.Duration("grpc_max_connection_age", time.Duration(math.MaxInt64), "Maximum age of a client connection before GoAway is sent.")
GRPCMaxConnectionAgeGrace = flag.Duration("grpc_max_connection_age_grace", time.Duration(math.MaxInt64), "Additional grace period after grpc_max_connection_age, after which connections are forcibly closed.")
}

// GRPCCheckServiceMap returns if we should register a gRPC service
Expand Down