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

Documented behavior for custom http.Transport wrt MaxIdleConnsPerHost field #93

Merged
merged 3 commits into from
Feb 9, 2018

Conversation

ewoutp
Copy link
Contributor

@ewoutp ewoutp commented Feb 9, 2018

Copy link
Member

@neunhoef neunhoef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Member

@mchacki mchacki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ewoutp ewoutp merged commit 894a0b3 into master Feb 9, 2018
@ewoutp ewoutp deleted the max_idle_conn_per_host branch February 9, 2018 08:40
Copy link
Member

@neunhoef neunhoef left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One additional comment suggestion, and a question about what the values are before we go in.

// When using a custom `http.Transport`, make sure to set the `MaxIdleConnsPerHost` field at least as
// high as the maximum number of concurrent requests you will make to your database.
// A lower number will cause the golang runtime to create additional connections and close them
// directly after use, resulting in a large number of connections in `TIME_WAIT` state.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should add a comment here that we set the default to at least 64 and that one should lower it if needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a line in master

httpTransport.MaxIdleConnsPerHost = DefaultMaxIdleConnsPerHost
}
defaultMaxIdleConns := 3 * DefaultMaxIdleConnsPerHost
if httpTransport.MaxIdleConns > 0 && httpTransport.MaxIdleConns < defaultMaxIdleConns {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems MaxIdleConnsPerHost is set to 0 here if nothing is set, is the same true for MaxIdleConns? If so, then we should write "== 0" here, otherwise we do not set out default if the user has not given anything.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Behavior for MaxIdleConns==0 is different. It means "unlimited"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants