Skip to content

Commit f348d3e

Browse files
committed
force http2 for clients and increase http2 server concurrency
1 parent e5a0528 commit f348d3e

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

proxy/receiver_servers.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ var (
1616
HTTPDefaultIdleTimeout = time.Duration(cli.GetEnvInt("HTTP_IDLE_TIMEOUT_SEC", 3600)) * time.Second
1717
HTTP2DefaultMaxUploadPerConnection = int32(cli.GetEnvInt("HTTP2_MAX_UPLOAD_PER_CONN", 32<<20)) // 32MiB
1818
HTTP2DefaultMaxUploadPerStream = int32(cli.GetEnvInt("HTTP2_MAX_UPLOAD_PER_STREAM", 8<<20)) // 8MiB
19+
HTTP2DefaultMaxConcurrentStreams = uint32(cli.GetEnvInt("HTTP2_MAX_CONCURRENT_STREAMS", 4096))
1920
)
2021

2122
type ReceiverProxyServers struct {
@@ -35,6 +36,7 @@ func StartReceiverServers(proxy *ReceiverProxy, userListenAddress, systemListenA
3536
IdleTimeout: HTTPDefaultIdleTimeout,
3637
}
3738
userH2 := http2.Server{
39+
MaxConcurrentStreams: HTTP2DefaultMaxConcurrentStreams,
3840
MaxUploadBufferPerConnection: HTTP2DefaultMaxUploadPerConnection,
3941
MaxUploadBufferPerStream: HTTP2DefaultMaxUploadPerStream,
4042
}
@@ -54,6 +56,7 @@ func StartReceiverServers(proxy *ReceiverProxy, userListenAddress, systemListenA
5456
IdleTimeout: HTTPDefaultIdleTimeout,
5557
}
5658
systemH2 := http2.Server{
59+
MaxConcurrentStreams: HTTP2DefaultMaxConcurrentStreams,
5760
MaxUploadBufferPerConnection: HTTP2DefaultMaxUploadPerConnection,
5861
MaxUploadBufferPerStream: HTTP2DefaultMaxUploadPerStream,
5962
}

proxy/utils.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,19 @@ func createTransportForSelfSignedCert(certPEM []byte) (*http.Transport, error) {
3232
if ok := certPool.AppendCertsFromPEM(certPEM); !ok {
3333
return nil, errCertificate
3434
}
35-
return &http.Transport{
35+
tr := &http.Transport{
3636
TLSClientConfig: &tls.Config{
3737
RootCAs: certPool,
3838
MinVersion: tls.VersionTLS12,
3939
},
40-
}, nil
40+
ForceAttemptHTTP2: true,
41+
}
42+
// Is required due to TLSCLientConfig field specified
43+
err := http2.ConfigureTransport(tr)
44+
if err != nil {
45+
return nil, err
46+
}
47+
return tr, nil
4148
}
4249

4350
func HTTPClientWithMaxConnections(maxOpenConnections int) *http.Client {

0 commit comments

Comments
 (0)