Skip to content

Commit

Permalink
Merge pull request #3 from erikgeiser/fix/fix-idle-connections-limit
Browse files Browse the repository at this point in the history
Increase Connection Pool Limit to Avoid Resource Exhaustion
  • Loading branch information
rtpt-alexanderneumann authored Sep 8, 2020
2 parents 4c643c2 + 03df1da commit 1eadfd1
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
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

0 comments on commit 1eadfd1

Please sign in to comment.