[GODRIVER-2168] Prevent unnecessary connection churn and timeout idle connections Created: 01/Oct/21  Updated: 24/Nov/21  Resolved: 24/Nov/21

Status: Closed
Project: Go Driver
Component/s: Connections, Options & Configuration
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Minor - P4
Reporter: James Hartig Assignee: Matt Dale
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Related
related to DRIVERS-1977 Add a default idle timeout for pooled... Backlog

 Description   

Currently there's only a single idle timeout that applies to all connections and by default there's no timeout. Without a timeout then a burst in traffic will leave unnecessary connections around indefinitely. If you set a timeout then you cause unnecessary churn if your pool is already at the minimum size.

Could there be some way to define a dynamic idle timeout where its x if the pool is more than the minimum but if its already at the minimum then its y. Maybe allow a user-defined function to be set to define it based on some pool stats that get sent to the function?

What does the Mongo team recommend to solve these 2 issues?



 Comments   
Comment by Matt Dale [ 24/Nov/21 ]

Sounds great! I'm closing this for now.

Comment by James Hartig [ 16/Nov/21 ]

Thanks for the detailed answer! Yes, I think that will work for now and the further enhancement will only help. Thanks again!

Comment by Matt Dale [ 10/Nov/21 ]

Hey james@getadmiral.com, thanks for the question! We've actually started trying to address the default idle timeout and interaction between maxIdleTimeMS and minPoolSize with DRIVERS-1977. That ticket (currently) recommends updating the specification for all drivers to use a 30-minute default idle timeout and only close idle connections if the pool size is greater than minPoolSize. If that change is adopted, each driver team (including the Go driver team) will update the driver behavior to match the spec.

As for what you can do right now, setting a high maxIdleTimeMS value like 30 minutes to 1 hour may mitigate some connection churn caused by the interaction between maxIdleTimeMS and minPoolSize by reducing how often connections are closed due to idle timeout. Does setting maxIdleTimeMS to a value like 1800000 (30 minutes) help manage connection pool size in your application?

Generated at Thu Feb 08 08:37:58 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.