Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved proxy http client setup #24

Merged
merged 2 commits into from
Apr 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions server/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ var (
RedisPrefix = GetEnv("REDIS_PREFIX", "prio-load-balancer:") // All redis keys will be prefixed with this
EnableErrorTestAPI = os.Getenv("ENABLE_ERROR_TEST_API") == "1" // will enable /debug/testLogLevels which prints errors and ends with a panic (also enabled if mock-node is used)
EnablePprof = os.Getenv("ENABLE_PPROF") == "1" // will enable /debug/pprof

ProxyMaxIdleConns = GetEnvInt("ProxyMaxIdleConns", 100)
ProxyMaxConnsPerHost = GetEnvInt("ProxyMaxConnsPerHost", 100)
ProxyMaxIdleConnsPerHost = GetEnvInt("ProxyMaxIdleConnsPerHost", 100)
ProxyIdleConnTimeout = time.Duration(GetEnvInt("ProxyIdleConnTimeout", 90)) * time.Second
)

func LogConfig(log *zap.SugaredLogger) {
Expand All @@ -44,5 +49,9 @@ func LogConfig(log *zap.SugaredLogger) {
"RedisPrefix", RedisPrefix,
"EnableErrorTestAPI", EnableErrorTestAPI,
"EnablePprof", EnablePprof,
"ProxyMaxIdleConns", ProxyMaxIdleConns,
"ProxyMaxConnsPerHost", ProxyMaxConnsPerHost,
"ProxyMaxIdleConnsPerHost", ProxyMaxIdleConnsPerHost,
"ProxyIdleConnTimeout", ProxyIdleConnTimeout,
)
}
10 changes: 9 additions & 1 deletion server/node_notee.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,15 @@ func NewNode(log *zap.SugaredLogger, uri string, jobC chan *SimRequest, numWorke
AddedAt: time.Now(),
jobC: jobC,
numWorkers: numWorkers,
client: &http.Client{},
client: &http.Client{
Timeout: ProxyRequestTimeout,
Transport: &http.Transport{
MaxIdleConns: ProxyMaxIdleConns,
MaxConnsPerHost: ProxyMaxConnsPerHost,
MaxIdleConnsPerHost: ProxyMaxIdleConnsPerHost,
IdleConnTimeout: ProxyIdleConnTimeout,
},
},
}
return node, nil
}
7 changes: 6 additions & 1 deletion server/node_tee.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,8 +109,13 @@ func NewNode(log *zap.SugaredLogger, uri string, jobC chan *SimRequest, numWorke
return nil, err
}
client = http.Client{
Timeout: ProxyRequestTimeout,
Transport: &http.Transport{
TLSClientConfig: tlsConfig,
TLSClientConfig: tlsConfig,
MaxIdleConns: ProxyMaxIdleConns,
MaxConnsPerHost: ProxyMaxConnsPerHost,
MaxIdleConnsPerHost: ProxyMaxIdleConnsPerHost,
IdleConnTimeout: ProxyIdleConnTimeout,
},
}
}
Expand Down
Loading