-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow to tune the read/write buffers for gRPC server #1218
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -116,14 +116,22 @@ type GRPCServerSettings struct { | |
|
||
// Configures the protocol to use TLS. | ||
// The default value is nil, which will cause the protocol to not use TLS. | ||
TLSCredentials *configtls.TLSServerSetting `mapstructure:"tls_credentials, omitempty"` | ||
TLSCredentials *configtls.TLSServerSetting `mapstructure:"tls_credentials,omitempty"` | ||
|
||
// MaxRecvMsgSizeMiB sets the maximum size (in MiB) of messages accepted by the server. | ||
MaxRecvMsgSizeMiB uint64 `mapstructure:"max_recv_msg_size_mib,omitempty"` | ||
MaxRecvMsgSizeMiB uint64 `mapstructure:"max_recv_msg_size_mib"` | ||
|
||
// MaxConcurrentStreams sets the limit on the number of concurrent streams to each ServerTransport. | ||
// It has effect only for streaming RPCs. | ||
MaxConcurrentStreams uint32 `mapstructure:"max_concurrent_streams,omitempty"` | ||
MaxConcurrentStreams uint32 `mapstructure:"max_concurrent_streams"` | ||
|
||
// The WriteBufferSize for client gRPC. See grpc.ReadBufferSize | ||
// (https://godoc.org/google.golang.org/grpc#ReadBufferSize). | ||
ReadBufferSize int `mapstructure:"read_buffer_size"` | ||
|
||
// The WriteBufferSize for client gRPC. See grpc.WriteBufferSize | ||
// (https://godoc.org/google.golang.org/grpc#WriteBufferSize). | ||
WriteBufferSize int `mapstructure:"write_buffer_size"` | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should not matter. We are not sending anything big from our servers, only tiny responses. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Correct but want to have them to be completed also because it may matter in a pull protocol. |
||
|
||
// Keepalive anchor for all the settings related to keepalive. | ||
Keepalive *KeepaliveServerConfig `mapstructure:"keepalive,omitempty"` | ||
|
@@ -191,6 +199,14 @@ func (gss *GRPCServerSettings) ToServerOption() ([]grpc.ServerOption, error) { | |
opts = append(opts, grpc.MaxConcurrentStreams(gss.MaxConcurrentStreams)) | ||
} | ||
|
||
if gss.ReadBufferSize > 0 { | ||
opts = append(opts, grpc.ReadBufferSize(gss.ReadBufferSize)) | ||
} | ||
|
||
if gss.WriteBufferSize > 0 { | ||
opts = append(opts, grpc.WriteBufferSize(gss.WriteBufferSize)) | ||
} | ||
|
||
// The default values referenced in the GRPC docs are set within the server, so this code doesn't need | ||
// to apply them over zero/nil values before passing these as grpc.ServerOptions. | ||
// The following shows the server code for applying default grpc.ServerOptions. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this make any difference? In my similar experiments with WebSockets reading buffers did not make any difference since we are reading in big chunks. But perhaps gRPC is different, it will be interesting to know if increasing this buffer size makes a difference.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I saw some difference in gRPC on my Mac not as much as on the client but still something.