Skip to content

Commit

Permalink
Limit concurrent S3 connections per host
Browse files Browse the repository at this point in the history
This commit limits the number of concurrent connections to encourage
connection reuse. `MaxIdleConnsPerHost` was already set to workaround
golang/go#13801 ("issue which made Go consume
all ephemeral ports").

We observed a similar issue when starting up Loki (using weaveworks
`common/aws` throught Cortex) which resulted in thousands of very small
S3 requests until memcached was seeded. This failed because of ephemeral
port exhaustion: while the application in fact would have reused
connections, it already failed as it sent all of them concurrently until
most of the requests failed.

`MaxConnsPerHost` can be used to limit the overall number of parallel
connections.
  • Loading branch information
JensErat committed Apr 14, 2020
1 parent 2708ba4 commit 9f296fe
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions aws/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ func ConfigFromURL(awsURL *url.URL) (*aws.Config, error) {
}).DialContext,
MaxIdleConns: 100,
IdleConnTimeout: 90 * time.Second,
MaxConnsPerHost: 100,
MaxIdleConnsPerHost: 100,
TLSHandshakeTimeout: 3 * time.Second,
ExpectContinueTimeout: 1 * time.Second,
Expand Down

0 comments on commit 9f296fe

Please sign in to comment.