Skip to content

Commit

Permalink
bump http client's MaxIdleConns and MaxIdleConnsPerHost
Browse files Browse the repository at this point in the history
The idea here is for Pilosa to behave better under high query load where a node
might be making many connections to the other nodes in the cluster in order to
support lots of concurrent batches of SetBit queries (for example). By allowing
for more idle connections and more idle connections per host, we reduce
connection churn, and allow more connections to be reused rather than creating
new ones and potentially having many stale sockets in the TIME_WAIT state. See
golang/go#16012
  • Loading branch information
jaffee committed Oct 31, 2017
1 parent 1819cf7 commit 53d4e5e
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion executor.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"errors"
"fmt"
"io/ioutil"
"net"
"net/http"
"net/url"
"sort"
Expand Down Expand Up @@ -57,7 +58,21 @@ type Executor struct {
// NewExecutor returns a new instance of Executor.
func NewExecutor() *Executor {
return &Executor{
HTTPClient: http.DefaultClient,
HTTPClient: &http.Client{
Transport: &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: (&net.Dialer{
Timeout: 30 * time.Second,
KeepAlive: 30 * time.Second,
DualStack: true,
}).DialContext,
MaxIdleConns: 1000,
MaxIdleConnsPerHost: 200,
IdleConnTimeout: 90 * time.Second,
TLSHandshakeTimeout: 10 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
},
},
}
}

Expand Down

0 comments on commit 53d4e5e

Please sign in to comment.