Skip to content

Commit

Permalink
[ENH] Add flags to the go binary for concurrency and stream processing.
Browse files Browse the repository at this point in the history
By default, most grpc implementations allow up to 100 concurrent
streams.  We have 200 concurrent requests, basically guaranteeing
queueing.  Expose the two gRPC options in Go that will allow us to tune.
  • Loading branch information
rescrv committed Jan 9, 2025
1 parent d9de2b7 commit bc286e7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 0 deletions.
3 changes: 3 additions & 0 deletions go/pkg/grpcutils/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ type GrpcConfig struct {
// BindAddress is the address to bind the GRPC server to.
BindAddress string

MaxConcurrentStreams uint32
NumStreamWorkers uint32

// GRPC mTLS config
CertPath string
KeyPath string
Expand Down
2 changes: 2 additions & 0 deletions go/pkg/grpcutils/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ type defaultGrpcServer struct {
func newDefaultGrpcProvider(name string, grpcConfig *GrpcConfig, registerFunc func(grpc.ServiceRegistrar)) (GrpcServer, error) {
var opts []grpc.ServerOption
opts = append(opts, grpc.MaxRecvMsgSize(maxGrpcFrameSize))
opts = append(opts, grpc.NumStreamWorkers(grpcConfig.NumStreamWorkers))
opts = append(opts, grpc.MaxConcurrentStreams(grpcConfig.MaxConcurrentStreams))
if grpcConfig.MTLSEnabled() {
cert, err := tls.LoadX509KeyPair(grpcConfig.CertPath, grpcConfig.KeyPath)
if err != nil {
Expand Down

0 comments on commit bc286e7

Please sign in to comment.