-
Notifications
You must be signed in to change notification settings - Fork 529
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
perf: set max conns idle per host as docappender max request #12035
Conversation
By default the http transport will use 2 as the max idle connections per host. The docappender client will send request a single host and will have at most MaxRequest appenders sharing the same client. To improve performance and connection reuse we set the number of max idle conns per host to MaxRequest
sync default value with docappender default
This pull request does not have a backport label. Could you fix it @kruskall? 🙏
NOTE: |
@@ -700,6 +700,7 @@ func (s *Runner) newFinalBatchProcessor( | |||
} | |||
esConfig.FlushInterval = time.Second | |||
esConfig.Config = elasticsearch.DefaultConfig() | |||
esConfig.MaxIdleConnsPerHost = 10 |
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.
Why setting it to 10
here and then only later to esConfig.MaxRequests
?
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.
10
is the default value
We overwrite this value with esConfig.MaxRequests
after the config has been unpacked.
I've made it more explicit.
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.
Other default values are set in the elasticsearch/config.go
; IMO the default value should also be set there.
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.
That would change the value for every ES client which might not be ideal.
The default value of 10
only makes sense for the docappender client because it's the same as the default number of max requests handled by the docappender.
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.
So in this case, shouldn't this default value then always be set via esConfig.MaxRequests
in line 724
? Why setting it to a hardcoded default, that easily gets outdated (as the docappender default value comes from a different source)?
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.
The hardcoded default is for when MaxRequests
is 0.
Without this line, MaxIdleConnsPerHost
will use a default value of 0 and the http.Transport
will use the internal default (which is 2).
The docappender on the other hand will use a default value of 10, leading to the same issue we have right now (resources being underused and connections being recreated).
We need to pass the es config before creating the es client which is then passed to the docappender so we can't do this in the go-docappender library.
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; would be good to have some actual numbers on this improvement.
Motivation/summary
By default the http transport will use 2 as the max idle connections per host.
The docappender client will send request a single host and will have at most
MaxRequest appenders sharing the same client. To improve performance and
connection reuse we set the number of max idle conns per host to MaxRequest
Checklist
apmpackage
have been made)For functional changes, consider:
How to test these changes
Related issues