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

Support configuration of minimum idle connections #141

Closed
mostafavahidi opened this issue Oct 27, 2021 · 4 comments
Closed

Support configuration of minimum idle connections #141

mostafavahidi opened this issue Oct 27, 2021 · 4 comments
Labels
type: enhancement A general enhancement
Milestone

Comments

@mostafavahidi
Copy link

Hi all,

Recently, my team has come across an issue where number of connections in the connection pool drops to 0 after some time that the pool is not used.
We want to be able to set some property in r2dbc-pool that allows us to keep a minimum number of idle connections regardless of the usage of the pool.

After some searching, I found that the apache DBCP library offers minIdle setting:
https://commons.apache.org/proper/commons-dbcp/configuration.html
minIdle: The minimum number of connections that can remain idle in the pool, without extra ones being created, or zero to create none.

Unfortunately, in r2dbc-pool, I haven't found a similar param. The following two params are similar but look like they would change the lifecycle behavior of the pool itself:
backgroundEvictionInterval & maxIdleTime

They're not quite what we're after. Is there a solution/hack that I can do that will allow me to set the minimum number of idle connections I want to keep at all times that I am missing?

If not, are there any plans that this will be added in the future?

Thank you for response,
Mostafa

@mp911de
Copy link
Member

mp911de commented Oct 28, 2021

You can use initialSize and ConnectionPool.warmup() to instruct the pool to create initialSize of connections. There's no way to keep a number of additional connections around that increased with each allocation. Reactor Pool allows for a AllocationStrategy but we do not accept allocation strategies to keep the configuration simple.

I wonder whether you could simply call warmup() periodically (e.g. through a Scheduler) to ensure a number of connections in the pool.

We have seen recently a number of reports (e.g. #140) that the connection pool connections deplete due to some improper connection releases. Mostly FYI, but that might play into this report as well.

@jonenst
Copy link

jonenst commented Nov 10, 2021

Hi,
I would like to have a similar feature. It seems like a very common requirement. For example HikariCP has it too. Do we need to open a bug report in reactor pool to allow r2dbc-pool to implement a minimum number of connections that are never closed, even if idle ?

@mp911de mp911de added the type: enhancement A general enhancement label Jun 23, 2022
@mp911de mp911de added this to the 0.9.1.RELEASE milestone Jun 23, 2022
@mp911de mp911de changed the title minIdle Property Request Support configuration of minimum idle connections Jun 23, 2022
mp911de added a commit that referenced this issue Jun 23, 2022
@mp911de
Copy link
Member

mp911de commented Jun 23, 2022

That's in place now. InitialSize is somewhat overlapping, if both values are configured, we're going to use the greater one.

@grantas33
Copy link

Currently, after maxIdleTime has passed all idle connections close and minIdle field does not have any effect. Is this a bug or expected behavior? I would expect that at least minIdle number of connections should never be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: enhancement A general enhancement
Projects
None yet
Development

No branches or pull requests

4 participants