Skip to content

Commit

Permalink
Add http client tuning
Browse files Browse the repository at this point in the history
  • Loading branch information
vdamle committed Nov 3, 2022
1 parent a544c8d commit 06de668
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion pkg/kldexerciser/kldexerciser.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import (
"encoding/json"
"fmt"
"io/ioutil"
"net"
"net/http"
"strconv"
"sync"
Expand Down Expand Up @@ -201,7 +202,24 @@ func (e *Exerciser) Start() (err error) {
log.Debug("Connecting workers. Count=", e.Workers)

// Connect the client
rpcClient, err := rpc.DialHTTPWithClient(e.URL, http.DefaultClient)
dialer := &net.Dialer{
Timeout: time.Duration(60) * time.Second,
KeepAlive: time.Duration(60) * time.Second,
DualStack: true,
}
transport := &http.Transport{
Proxy: http.ProxyFromEnvironment,
DialContext: dialer.DialContext,
MaxIdleConns: 500,
MaxIdleConnsPerHost: 500,
MaxConnsPerHost: 500,
IdleConnTimeout: time.Duration(100) * time.Second,
ExpectContinueTimeout: 0, // Send body immediately on the back-end
}
httpClient := &http.Client{
Transport: transport,
}
rpcClient, err := rpc.DialHTTPWithClient(e.URL, httpClient)
if err != nil {
return fmt.Errorf("connection to %s failed: %s", e.URL, err)
}
Expand Down

0 comments on commit 06de668

Please sign in to comment.