Skip to content

Constrain the number of unused connections kept in the pool - #23815

Closed
matthewd wants to merge 1 commit into
rails:masterfrom
matthewd:dynamic-connection-pool
Closed

matthewd wants to merge 1 commit into
rails:masterfrom
matthewd:dynamic-connection-pool

Conversation

@matthewd

Copy link
Copy Markdown
Member

Just as we don't fill the pool with connections at boot, we generally needn't maintain a full pool just because we once needed that many.

For maximum compatibility, this behaviour is disabled by default, by setting the minimum to match the configured maximum. But by choosing to configure a lower minimum, and setting a suitable reaping_frequency (e.g., 10 minutes), you can now get a dynamic pool that keeps just what it is likely to need in the near future.

@thedarkone I'm pretty sure this is terrible 😕

Just as we don't fill the pool with connections at boot, we generally
needn't maintain a full pool just because we once needed that many.

For maximum compatibility, this behaviour is disabled by default, by
setting the minimum to match the configured maximum. But by choosing to
configure a lower minimum, and setting a suitable reaping_frequency
(e.g., 10 minutes), you can now get a dynamic pool that keeps just what
it is likely to need in the near future.
@matthewd matthewd self-assigned this Feb 22, 2016

# default max pool size to 5
@size = (spec.config[:pool] && spec.config[:pool].to_i) || 5
@minimum_size = (spec.config[:pool_minimum] && spec.config[:pool_minimum].to_i) || @size

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should check and raise if @minimum_size > @size.

@matthewd

Copy link
Copy Markdown
Member Author

Addressed by #31221

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants