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

fix(idtoken): increase MaxIdleConnsPerHost to 100 in NewClient #1754

Merged
merged 2 commits into from Nov 21, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion idtoken/idtoken.go
Expand Up @@ -54,7 +54,9 @@ func NewClient(ctx context.Context, audience string, opts ...ClientOption) (*htt
// Skip DialSettings validation so added TokenSource will not conflict with user
// provided credentials.
opts = append(opts, option.WithTokenSource(ts), internaloption.SkipDialSettingsValidation())
t, err := htransport.NewTransport(ctx, http.DefaultTransport, opts...)
httpTransport := http.DefaultTransport.(*http.Transport).Clone()
httpTransport.MaxIdleConnsPerHost = 100
Copy link
Member

Choose a reason for hiding this comment

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

This seems like a large increase. The default when not set is 2 for comparison. I wonder if there is a different way we could enable users to do something like this.

Copy link
Member Author

Choose a reason for hiding this comment

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

This is the same default set in transport/http/dial.go. See some potentially relevant discussion here.

Copy link
Member Author

Choose a reason for hiding this comment

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

@david-gang Do you have any opinion on hardcoding to 100 here, as opposed to flexible configuration or some other value?

Copy link

Choose a reason for hiding this comment

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

@quartzmo 100 is fine for me. In the product i work on, we have 100 hardcoded for every http client.

t, err := htransport.NewTransport(ctx, httpTransport, opts...)
if err != nil {
return nil, err
}
Expand Down