benchmark: Enable server keepalive in benchmarks (#3196)

This commit is contained in:
Easwar Swaminathan 2019-11-20 09:06:10 -08:00 committed by GitHub
parent 24b653e8cc
commit 7c1d326729
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 14 additions and 1 deletions

View File

@ -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,