-
Notifications
You must be signed in to change notification settings - Fork 81
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this 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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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"
Info came from https://groups.google.com/forum/#!topic/golang-nuts/WjFjmtqg3kA