From 7c1d326729dc9b0a07135f8902ddcc050ff8ab64 Mon Sep 17 00:00:00 2001 From: Easwar Swaminathan Date: Wed, 20 Nov 2019 09:06:10 -0800 Subject: [PATCH] benchmark: Enable server keepalive in benchmarks (#3196) --- benchmark/benchmain/main.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/benchmark/benchmain/main.go b/benchmark/benchmain/main.go index 4dddb291b..b238c7403 100644 --- a/benchmark/benchmain/main.go +++ b/benchmark/benchmain/main.go @@ -143,8 +143,11 @@ var ( networkModeWAN: latency.WAN, networkLongHaul: latency.Longhaul, } - keepaliveTime = 10 * time.Second // this is the minimum allowed + keepaliveTime = 10 * time.Second keepaliveTimeout = 1 * time.Second + // This is 0.8*keepaliveTime to prevent connection issues because of server + // keepalive enforcement. + keepaliveMinTime = 8 * time.Second ) // runModes indicates the workloads to run. This is initialized with a call to @@ -275,6 +278,16 @@ func makeClient(bf stats.Features) (testpb.BenchmarkServiceClient, func()) { ) } if bf.EnableKeepalive { + sopts = append(sopts, + grpc.KeepaliveParams(keepalive.ServerParameters{ + Time: keepaliveTime, + Timeout: keepaliveTimeout, + }), + grpc.KeepaliveEnforcementPolicy(keepalive.EnforcementPolicy{ + MinTime: keepaliveMinTime, + PermitWithoutStream: true, + }), + ) opts = append(opts, grpc.WithKeepaliveParams(keepalive.ClientParameters{ Time: keepaliveTime,