-
Notifications
You must be signed in to change notification settings - Fork 450
Disable pre-fetching, limit conn pool and reuse db connection #79
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
Disable pre-fetching, limit conn pool and reuse db connection #79
Conversation
…l size and re-use database connection to MongoDB
|
I ran a test with 100 gets to the /metrics endpoint for 'master' and this PR. It seems go tracks 25% less CPU used with these changes: |
|
I removed a .Ping() on the mgo.Session that I added initially as mgo handles this for us. After this commit the CI system detected a race condition in MongodbCollector.getSession that needed to be fixed with a sync.Mutex lock to stop the race condition of making the session in many goroutines. |
…current calls. Moved session SocketTimeout to no longer be forever
|
I ran some ab (Apache Bench) tests and noticed a deadlock in the .getSession() logic at concurrency. This was fixed with returning a .Copy() of the database session (stolen from mongo-tools/common/db .SessionProvider). This should be the final change for this PR. |
|
@AlekSi / @michaelcoburn: anything holding this PR back? I think this would be very beneficial to rollout asap |
|
It is currently planned for PMM 1.6. |
|
@timvaillancourt Do you think we should also set |
On many systems I've seen the mongodb_exporter use very high CPU % under PMM 1.2.x. This PR aims to reduce some of the work the mgo driver is doing and reduce the amount of connections/log-noise from reconnecting each scrape.