From e5cb7b52b21d5e3f1526dc42058928af871eaf46 Mon Sep 17 00:00:00 2001 From: Erik Geiser Date: Sun, 6 Sep 2020 15:14:00 +0200 Subject: [PATCH 1/2] Increase MaxIdleConns(PerHost) --- response/runner.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/response/runner.go b/response/runner.go index 1f63fa1..85bfd5b 100644 --- a/response/runner.go +++ b/response/runner.go @@ -48,6 +48,8 @@ func NewTransport(insecure bool, TLSClientCertKeyFilename string, disableHTTP2 b ExpectContinueTimeout: 1 * time.Second, IdleConnTimeout: 15 * time.Second, TLSClientConfig: &tls.Config{}, + MaxIdleConns: 100, + MaxIdleConnsPerHost: 100, } if insecure { From 03df1da42f3cbd961be7860113a18f672608dd3d Mon Sep 17 00:00:00 2001 From: Erik Geiser Date: Mon, 7 Sep 2020 21:26:15 +0200 Subject: [PATCH 2/2] Allow as many idle conns as threads --- cmd/fuzz/main.go | 3 ++- cmd/test/main.go | 3 ++- response/runner.go | 7 ++++--- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/cmd/fuzz/main.go b/cmd/fuzz/main.go index 572e0fa..c528d74 100644 --- a/cmd/fuzz/main.go +++ b/cmd/fuzz/main.go @@ -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 } diff --git a/cmd/test/main.go b/cmd/test/main.go index 0964fe8..2320c2f 100644 --- a/cmd/test/main.go +++ b/cmd/test/main.go @@ -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 } diff --git a/response/runner.go b/response/runner.go index 85bfd5b..72e549a 100644 --- a/response/runner.go +++ b/response/runner.go @@ -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{ @@ -48,8 +49,8 @@ func NewTransport(insecure bool, TLSClientCertKeyFilename string, disableHTTP2 b ExpectContinueTimeout: 1 * time.Second, IdleConnTimeout: 15 * time.Second, TLSClientConfig: &tls.Config{}, - MaxIdleConns: 100, - MaxIdleConnsPerHost: 100, + MaxIdleConns: concurrentRequests, + MaxIdleConnsPerHost: concurrentRequests, } if insecure {