From ac3b3edb5eb7f197fe833bd7a8687d5c914e90ae Mon Sep 17 00:00:00 2001 From: tangenta Date: Tue, 8 Nov 2022 23:55:33 +0800 Subject: [PATCH] server: set the keepalive MinTime for gRPC server --- server/rpc_server.go | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/rpc_server.go b/server/rpc_server.go index 7053872f19aa7..24b5d158edfe6 100644 --- a/server/rpc_server.go +++ b/server/rpc_server.go @@ -55,6 +55,12 @@ func NewRPCServer(config *config.Config, dom *domain.Domain, sm util.SessionMana Time: time.Duration(config.Status.GRPCKeepAliveTime) * time.Second, Timeout: time.Duration(config.Status.GRPCKeepAliveTimeout) * time.Second, }), + grpc.KeepaliveEnforcementPolicy(keepalive.EnforcementPolicy{ + // Allow clients send consecutive pings in every 5 seconds. + // The default value of MinTime is 5 minutes, + // which is too long compared with 10 seconds of TiDB's keepalive time. + MinTime: 5 * time.Second, + }), grpc.MaxConcurrentStreams(uint32(config.Status.GRPCConcurrentStreams)), grpc.InitialWindowSize(int32(config.Status.GRPCInitialWindowSize)), grpc.MaxSendMsgSize(config.Status.GRPCMaxSendMsgSize),