From 7cf211b056a66a72bb9dac7399d6a0941b88b32e Mon Sep 17 00:00:00 2001 From: Derek Collison Date: Wed, 18 Sep 2019 11:40:00 -0700 Subject: [PATCH] Use multiple connections to amortize TLS Signed-off-by: Derek Collison --- server/accounts.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/server/accounts.go b/server/accounts.go index 05a84cb3..77170d4d 100644 --- a/server/accounts.go +++ b/server/accounts.go @@ -1801,12 +1801,18 @@ func NewURLAccResolver(url string) (*URLAccResolver, error) { if !strings.HasSuffix(url, "/") { url += "/" } - // Do basic test to see if anyone is home. - // FIXME(dlc) - Make timeout configurable post MVP. + + // FIXME(dlc) - Make timeout and others configurable. + // We create our own transport to amortize TLS. + tr := &http.Transport{ + MaxIdleConns: 10, + IdleConnTimeout: 30 * time.Second, + } ur := &URLAccResolver{ url: url, - c: &http.Client{Timeout: 2 * time.Second}, + c: &http.Client{Timeout: 2 * time.Second, Transport: tr}, } + // Do basic test to see if anyone is home. if _, err := ur.Fetch(""); err != nil { return nil, err }