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

adding postgres max idle connections configuration #2020

Merged
merged 9 commits into from
May 27, 2021

Conversation

nikita15p
Copy link
Contributor

@nikita15p nikita15p commented May 21, 2021

Summary

Currently maximum idle connections are not configurable for postgres db.

Full changelog

  • [Implement ...] Added maxidleconnections to be configurable for postgres db
  • [Fix ...] na

Issues resolved

Fix NA

Documentation

Reference: https://golang.org/src/database/sql/sql.go

Testing

  • Unit tests
  • E2E tests
  • Manual testing on Universal
  • Manual testing on Kubernetes

@nikita15p nikita15p requested a review from a team as a code owner May 21, 2021 10:50
@nikita15p nikita15p changed the title Idleconn adding idle connections configuration May 21, 2021
@nikita15p nikita15p changed the title adding idle connections configuration adding postgres max idle connections configuration May 21, 2021
Signed-off-by: nikita15p <nikita15p@gmail.com>
Copy link
Contributor

@jakubdyszkiewicz jakubdyszkiewicz left a comment

Choose a reason for hiding this comment

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

thanks for the contribution! some minor things to fix and we can move forward with this

pkg/config/app/kuma-cp/kuma-cp.defaults.yaml Show resolved Hide resolved
pkg/config/app/kuma-cp/kuma-cp.defaults.yaml Outdated Show resolved Hide resolved
pkg/config/loader_test.go Show resolved Hide resolved
Signed-off-by: nikita15p <nikita15p@gmail.com>
@nikita15p
Copy link
Contributor Author

@jakubdyszkiewicz Please review

pkg/config/app/kuma-cp/kuma-cp.defaults.yaml Show resolved Hide resolved
@@ -29,6 +29,9 @@ store:
# Maximum number of open connections to the database
# `0` value means number of open connections is unlimited
maxOpenConnections: 0 # ENV: KUMA_STORE_POSTGRES_MAX_OPEN_CONNECTIONS
# Maximum number of connections in the idle connection pool
# <0 value means no idle connections and 0 means default max idle connections
maxIdleConnections: 0 # ENV: KUMA_STORE_POSTGRES_MAX_IDLE_CONNECTIONS
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm looking at https://golang.org/src/database/sql/sql.go. There are also following settings:

	maxLifetime       time.Duration          // maximum amount of time a connection may be reused
	maxIdleTime       time.Duration          // maximum amount of time a connection may be idle before being closed

That are default by zero and I'm looking at connectionCleanerRunLocked implementation. Does it mean that once the connection is created it is never closed now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, these values are 0 by default and the connections open/idle do not close by its age. If we have idle connections configured, it will use already open connections and will improve performance.

@jakubdyszkiewicz jakubdyszkiewicz merged commit f502241 into kumahq:master May 27, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants