-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Add generic connection pooling framework and enable PostgreSQL scaler to reuse DB connections #7248
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
base: main
Are you sure you want to change the base?
Conversation
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
|
Thank you for your contribution! 🙏 Please understand that we will do our best to review your PR and give you feedback as soon as possible, but please bear with us if it takes a little longer as expected. While you are waiting, make sure to:
Once the initial tests are successful, a KEDA member will ensure that the e2e tests are run. Once the e2e tests have been successfully completed, the PR may be merged at a later date. Please be patient. Learn more about our contribution guide. |
|
Hey @JorTurFer 👋 This is my first contribution, so I’d really appreciate your guidance and any feedback you can share. Thanks a lot for all your help so far! |
|
Hey @JorTurFer , |
|
Regardless of the content of the PR (which I didn't look at yet), there are definitely a number of jobs that have failed. You might want to look into those. |
fa88420 to
d938d5b
Compare
Signed-off-by: smartaquarius10 <[email protected]>
Signed-off-by: smartaquarius10 <[email protected]>
Signed-off-by: smartaquarius10 <[email protected]>
Signed-off-by: smartaquarius10 <[email protected]>
Signed-off-by: smartaquarius10 <[email protected]>
Signed-off-by: smartaquarius10 <[email protected]>
Signed-off-by: smartaquarius10 <[email protected]>
Signed-off-by: smartaquarius10 <[email protected]>
Signed-off-by: smartaquarius10 <[email protected]>
Signed-off-by: smartaquarius10 <[email protected]>
ddb2200 to
870cbf9
Compare
Signed-off-by: bhasin tanul <[email protected]>
Signed-off-by: Tan <[email protected]>
|
Hello @rickbrouwer , |
WHAT
Introduces connection pooling capability in KEDA. This allows scalers (starting with PostgreSQL) to reuse existing DB connections rather than opening new ones for every trigger evaluation. The design is generic and can be extended to other targets (e.g., Redis, SQS, MySQL) in future, if needed.
WHY
The current PostgreSQL scaler establishes a new DB connection for every trigger query, which can lead to connection exhaustion under high ScaledObject counts. Connection pooling solves this by sharing a finite set of connections across multiple scalers, reducing DB load and improving operator stability.
HOW
Library used:
pgxpoolNew package:
pkg/scalers/connectionpool/Created Pooling Manager
(<scaler>.<host>.<db>), ensuring isolation per database target.Max connections or any other property can be sent from config map and can be live reloaded
At line
#214in filepkg/scalers/postgresql_scaler.goadded a smallif s.connection != nil {as it was creating error logs if secret passed is wrong then we doesn't create connection object asgetConnectioncalled onceOld behavior (new DB connection per trigger) replaced with pooled base access (via kind of factory, singleton and strategy pattern):
TEST CASES(on EKS)
PENDING
Checklist
Fixes #6955
Relates to 7206