-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
connection pool: max idle connections implementation #17443
Merged
harshit-gangal
merged 8 commits into
vitessio:main
from
planetscale:max-idle-connections
Jan 10, 2025
Merged
Changes from 6 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
e8eb29e
connection pool: max idle connections implementation
harshit-gangal ea13abf
fix: idle connection count logic and added unit test
harshit-gangal 9661dc3
added max-idle-count as pool config
harshit-gangal 6ceefe8
added idle count metric and tests
harshit-gangal b1c9b18
update idle count on changing pool capacity after the capacity is app…
harshit-gangal 1e37131
update flag description
harshit-gangal 9e49a1b
added release notes
harshit-gangal 8ed9e86
Merge remote-tracking branch 'upstream/main' into max-idle-connections
harshit-gangal File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be better to not always immediately close, or just close with some random chance, so the connection churn is not really aggressive when there's high active transaction churn?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We have to maintain a pool of some free available connections, otherwise there will be time spend in acquiring the connection for executing the query.
Even during high transactions, there will be log of
get
andput
call that will happen on the pool, so we have to wait till the free connections become more than a certain limit before we start closing them.Otherwise the application will see degradation in performance on high QPS
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, I said "not always". By which I meant, randomize closing after the idle time had reached.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Another way to look at it would be to make the idle time random, say between 1x and 2x of the config value, so we don't try and close lots of connections at the same time, after a spike in load.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already have support for idle time. This is implementation for idle count. You can choose to use either or both settings on the pool.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, but the idle time and counts are hard thresholds, which will cause large numbers of connections to get closed at the same time, if a large number were opened at the same time, which is not necessary, and could be smoothed out a little.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not like maximum connection lifetime which we already smooth out.
In case of idle connection, it is reasonable to churn them as and when they exceed the limit.
There is no active user looking for those connections, therefore they became idle.