Skip to content

Commit 2e4e3b2

Browse files
committed
refactor: simplify S3 HTTP config to single parameter
Per maintainer feedback - only expose MaxIdleConnsPerHost since it's the only setting that differs from Go defaults (2 → 100). Other HTTP transport settings use sensible Go defaults.
1 parent 97a0a55 commit 2e4e3b2

2 files changed

Lines changed: 6 additions & 43 deletions

File tree

README.md

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -824,18 +824,8 @@ Usage of imagor:
824824
-s3-result-storage-endpoint string
825825
Optional S3 Storage Endpoint to override default
826826

827-
-s3-http-max-idle-conns int
828-
S3 HTTP client max idle connections across all hosts (default 100)
829827
-s3-http-max-idle-conns-per-host int
830-
S3 HTTP client max idle connections per host. Increase for high-throughput workloads (default 100)
831-
-s3-http-max-conns-per-host int
832-
S3 HTTP client max connections per host. 0 means unlimited (default 0)
833-
-s3-http-idle-conn-timeout duration
834-
S3 HTTP client idle connection timeout (default 90s)
835-
-s3-http-response-header-timeout duration
836-
S3 HTTP client response header timeout. 0 means no timeout (default 0)
837-
-s3-http-disable-keep-alives
838-
S3 HTTP client disable keep-alives. Not recommended for production
828+
S3 HTTP client max idle connections per host (default 100, Go default is 2)
839829

840830
-gcloud-safe-chars string
841831
Google Cloud safe characters to be excluded from image key escape. Set -- for no-op

config/awsconfig/awsconfig.go

Lines changed: 5 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -98,18 +98,8 @@ func WithAWS(fs *flag.FlagSet, cb func() (*zap.Logger, bool)) imagor.Option {
9898
s3StorageClass = fs.String("s3-storage-class", "STANDARD",
9999
"S3 File Storage Class. Available values: REDUCED_REDUNDANCY, STANDARD_IA, ONEZONE_IA, INTELLIGENT_TIERING, GLACIER, DEEP_ARCHIVE. Default: STANDARD.")
100100

101-
s3HTTPMaxIdleConns = fs.Int("s3-http-max-idle-conns", 100,
102-
"S3 HTTP client max idle connections across all hosts")
103101
s3HTTPMaxIdleConnsPerHost = fs.Int("s3-http-max-idle-conns-per-host", 100,
104-
"S3 HTTP client max idle connections per host. Increase for high-throughput workloads")
105-
s3HTTPMaxConnsPerHost = fs.Int("s3-http-max-conns-per-host", 0,
106-
"S3 HTTP client max connections per host. 0 means unlimited")
107-
s3HTTPIdleConnTimeout = fs.Duration("s3-http-idle-conn-timeout", 90*time.Second,
108-
"S3 HTTP client idle connection timeout")
109-
s3HTTPResponseHeaderTimeout = fs.Duration("s3-http-response-header-timeout", 0,
110-
"S3 HTTP client response header timeout. 0 means no timeout")
111-
s3HTTPDisableKeepAlives = fs.Bool("s3-http-disable-keep-alives", false,
112-
"S3 HTTP client disable keep-alives. Not recommended for production")
102+
"S3 HTTP client max idle connections per host (Go default is 2, increase for high-throughput workloads)")
113103

114104
_, _ = cb()
115105
)
@@ -120,14 +110,7 @@ func WithAWS(fs *flag.FlagSet, cb func() (*zap.Logger, bool)) imagor.Option {
120110

121111
ctx := context.Background()
122112

123-
httpClient := createHTTPClient(
124-
*s3HTTPMaxIdleConns,
125-
*s3HTTPMaxIdleConnsPerHost,
126-
*s3HTTPMaxConnsPerHost,
127-
*s3HTTPIdleConnTimeout,
128-
*s3HTTPResponseHeaderTimeout,
129-
*s3HTTPDisableKeepAlives,
130-
)
113+
httpClient := createHTTPClient(*s3HTTPMaxIdleConnsPerHost)
131114

132115
var loaderCfg, storageCfg, resultStorageCfg aws.Config
133116
var err error
@@ -243,28 +226,18 @@ func WithAWS(fs *flag.FlagSet, cb func() (*zap.Logger, bool)) imagor.Option {
243226
}
244227
}
245228

246-
func createHTTPClient(
247-
maxIdleConns int,
248-
maxIdleConnsPerHost int,
249-
maxConnsPerHost int,
250-
idleConnTimeout time.Duration,
251-
responseHeaderTimeout time.Duration,
252-
disableKeepAlives bool,
253-
) *http.Client {
229+
func createHTTPClient(maxIdleConnsPerHost int) *http.Client {
254230
transport := &http.Transport{
255231
Proxy: http.ProxyFromEnvironment,
256232
DialContext: (&net.Dialer{
257233
Timeout: 30 * time.Second,
258234
KeepAlive: 30 * time.Second,
259235
}).DialContext,
260-
MaxIdleConns: maxIdleConns,
236+
MaxIdleConns: 100,
261237
MaxIdleConnsPerHost: maxIdleConnsPerHost,
262-
MaxConnsPerHost: maxConnsPerHost,
263-
IdleConnTimeout: idleConnTimeout,
238+
IdleConnTimeout: 90 * time.Second,
264239
TLSHandshakeTimeout: 10 * time.Second,
265240
ExpectContinueTimeout: 1 * time.Second,
266-
ResponseHeaderTimeout: responseHeaderTimeout,
267-
DisableKeepAlives: disableKeepAlives,
268241
ForceAttemptHTTP2: true,
269242
}
270243

0 commit comments

Comments
 (0)