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 Connection Pool Limit to Avoid Resource Exhaustion #3

Merged
merged 2 commits into from
Sep 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion cmd/fuzz/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,8 @@ func startRunners(ctx context.Context, opts *Options, in <-chan string) (<-chan
out := make(chan response.Response)

var wg sync.WaitGroup
transport, err := response.NewTransport(opts.Request.Insecure, opts.Request.TLSClientKeyCertFile, opts.Request.DisableHTTP2)
transport, err := response.NewTransport(opts.Request.Insecure, opts.Request.TLSClientKeyCertFile,
opts.Request.DisableHTTP2, opts.Threads)
if err != nil {
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion cmd/test/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ func run(ctx context.Context, g *errgroup.Group, opts *Options, args []string) e

output := make(chan response.Response, 1)

tr, err := response.NewTransport(opts.Request.Insecure, opts.Request.TLSClientKeyCertFile, opts.Request.DisableHTTP2)
tr, err := response.NewTransport(opts.Request.Insecure, opts.Request.TLSClientKeyCertFile,
opts.Request.DisableHTTP2, 1)
if err != nil {
return err
}
Expand Down
5 changes: 4 additions & 1 deletion response/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ type Runner struct {
const DefaultBodyBufferSize = 5 * 1024 * 1024

// NewTransport creates a new shared transport for clients to use.
func NewTransport(insecure bool, TLSClientCertKeyFilename string, disableHTTP2 bool) (*http.Transport, error) {
func NewTransport(insecure bool, TLSClientCertKeyFilename string,
disableHTTP2 bool, concurrentRequests int) (*http.Transport, error) {
// for timeouts, see
// https://blog.cloudflare.com/the-complete-guide-to-golang-net-http-timeouts/
tr := &http.Transport{
Expand All @@ -48,6 +49,8 @@ func NewTransport(insecure bool, TLSClientCertKeyFilename string, disableHTTP2 b
ExpectContinueTimeout: 1 * time.Second,
IdleConnTimeout: 15 * time.Second,
TLSClientConfig: &tls.Config{},
MaxIdleConns: concurrentRequests,
MaxIdleConnsPerHost: concurrentRequests,
}

if insecure {
Expand Down