Skip to content
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

Increase the allowed concurrent gRPC streams #16327

Merged
merged 5 commits into from Jul 20, 2022
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
20 changes: 20 additions & 0 deletions vault/cluster/cluster.go
Expand Up @@ -6,9 +6,11 @@ import (
"crypto/x509"
"errors"
"fmt"
"math"
"net"
"net/url"
"os"
"strconv"
"sync"
"sync/atomic"
"time"
Expand Down Expand Up @@ -73,6 +75,20 @@ type Listener struct {
}

func NewListener(networkLayer NetworkLayer, cipherSuites []uint16, logger log.Logger, idleTimeout time.Duration) *Listener {

maxStreams := math.MaxUint32
if override := os.Getenv("VAULT_GRPC_MAX_STREAMS"); override != "" {
i, err := strconv.Atoi(override)
if err != nil {
logger.Warn("vault grpc max streams override must be an integer", "value", override)
} else if i < 0 || i > math.MaxUint32 {
logger.Warn("vault grpc max streams override out of range", "value", i)
} else {
maxStreams = i
logger.Info("overriding grpc max streams", "value", i)
}
}

// Create the HTTP/2 server that will be shared by both RPC and regular
// duties. Doing it this way instead of listening via the server and gRPC
// allows us to re-use the same port via ALPN. We can just tell the server
Expand All @@ -81,6 +97,10 @@ func NewListener(networkLayer NetworkLayer, cipherSuites []uint16, logger log.Lo
// Our forwarding connections heartbeat regularly so anything else we
// want to go away/get cleaned up pretty rapidly
IdleTimeout: idleTimeout,

// By default this is 250 which can be too small on high traffic
// clusters with many forwarded or replication gRPC connections.
MaxConcurrentStreams: uint32(maxStreams),
}

return &Listener{
Expand Down