-
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
base: main
Are you sure you want to change the base?
Conversation
Review ChecklistHello reviewers! 👋 Please follow this checklist when reviewing this Pull Request. General
Tests
Documentation
New flags
If a workflow is added or modified:
Backward compatibility
|
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #17443 +/- ##
==========================================
- Coverage 67.67% 67.66% -0.01%
==========================================
Files 1583 1583
Lines 254363 254394 +31
==========================================
- Hits 172140 172137 -3
- Misses 82223 82257 +34 ☔ View full report in Codecov by Sentry. |
Signed-off-by: Harshit Gangal <[email protected]>
Signed-off-by: Harshit Gangal <[email protected]>
10025af
to
ea13abf
Compare
Signed-off-by: Harshit Gangal <[email protected]>
Signed-off-by: Harshit Gangal <[email protected]>
…lied to the pool Signed-off-by: Harshit Gangal <[email protected]>
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.
LGTM 👍
Signed-off-by: Harshit Gangal <[email protected]>
@@ -407,6 +432,23 @@ func (pool *ConnPool[C]) put(conn *Pooled[C]) { | |||
} | |||
} | |||
|
|||
// closeOnIdleLimitReached closes a connection if the number of idle connections (active - inuse) in the pool | |||
// exceeds the idleCount limit. It returns true if the connection is closed, false otherwise. | |||
func (pool *ConnPool[C]) closeOnIdleLimitReached(conn *Pooled[C]) bool { |
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
and put
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.
LGTM
Description
This PR adds support for maximum idle connection in the pool.
The 3 pools gets it's own parameter for configuration:
queryserver-config-query-pool-max-idle-count
queryserver-config-stream-pool-max-idle-count
queryserver-config-txpool-max-idle-count
Related Issue(s)
Checklist
Deployment Notes