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

Add Pool Idle Timeout to control connection pool #343

Open
David-Engel opened this issue Dec 4, 2019 · 4 comments
Open

Add Pool Idle Timeout to control connection pool #343

David-Engel opened this issue Dec 4, 2019 · 4 comments
Assignees
Labels
💡 Enhancement Issues that are feature requests for the drivers we maintain.

Comments

@David-Engel
Copy link
Contributor

David-Engel commented Dec 4, 2019

From an internal email thread asking about ADO.NET connection pooling, we have this feature request from an ISV:

Is your feature request related to a problem? Please describe.

Right now, connections returned to the pool are automatically managed and closed/disposed from the pool after 4-8 minutes of idle time. This request is to be able to configurable the amount of time a connection can be idle in the pool before it is closed. "Pool Idle Timeout".

Describe the solution you'd like

A new connection string setting, "Pool Idle Timeout" which defines the number of seconds a connection can be idle in the pool before it is automatically closed.

Describe alternatives you've considered

Letting the 4-8 minute auto close do its thing. Using ClearPool() and ClearAllPools().

@David-Engel David-Engel added the 💡 Enhancement Issues that are feature requests for the drivers we maintain. label Dec 4, 2019
@cheenamalhotra cheenamalhotra added this to the 2.0.0 milestone Dec 9, 2019
@cheenamalhotra cheenamalhotra self-assigned this Dec 9, 2019
@cheenamalhotra cheenamalhotra modified the milestones: 2.0.0, Future May 22, 2020
@roji
Copy link
Member

roji commented May 22, 2020

FYI Npgsql has this option under the name Connection Idle Lifetime.

@saurabh500
Copy link
Contributor

@David-Engel wouldnt simply increasing the Min Pool Size help?
Also I was wondering what guidance would the application author use to set the connection lifetime?
@roji how do customers of Npgsql know what value to set for this connection string param?

@roji
Copy link
Member

roji commented Jul 2, 2024

@saurabh500 yeah, Connection Idle Lifetime and Pruning Interval are what control Npgsql's connection pool pruning mechanism; once you have more than Min Pool Size idle connections in the pool, these two parameters determine how/when connections get pruned. The default value for this is 300 (5 minutes), but users can e.g. dial it down if they want more aggressive pruning; that would reduce the overall idle connection strain on the server, but can cause more thrashing if new physical connections need to be created because the previous ones were pruned etc.

Note that Npgsql doesn't track specific connections for pruning reasons. In other words, we don't care if a single connection was idle for 5 minutes, or different connections came in and out of the pool but 1 was always idle in there. We simply sample the pool status every given interval, and if we see a constant idle situation for Connection IdleL Lifetime, we start pruning etc.

@David-Engel
Copy link
Contributor Author

@saurabh500
I've forgotten any additional context from the customer, at this point. But idle timeout is a pretty common knob in pooling libraries to control how aggressively idle connections are pruned.

Examples:
HilariCP
Apache Commons CP
C3PO

@cheenamalhotra cheenamalhotra removed this from the Future milestone Oct 5, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💡 Enhancement Issues that are feature requests for the drivers we maintain.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants