Skip to content

Commit

Permalink
benchmark: Enable server keepalive in benchmarks (#3196)
Browse files Browse the repository at this point in the history
  • Loading branch information
easwars authored Nov 20, 2019
1 parent 24b653e commit 7c1d326
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion benchmark/benchmain/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 7c1d326

Please sign in to comment.