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

Adds new connection application name setting #16690

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

cicdw
Copy link
Member

@cicdw cicdw commented Jan 11, 2025

This PR exposes a new setting PREFECT_SERVER_DATABASE_CONNECTION_APP_NAME that allows users to specify an application name for connections opened to PostgreSQL databases. This allows us and users to hypothetically use different values for this field when running the webserver connection pools vs. the services connection pools (which are currently the same connection pool if using prefect server start but I want to experiment with a pattern where they are different).

Running SELECT application_name, datname, state, count(*) FROM pg_stat_activity group by datname, state, application_name order by count desc; let's you see this field along with how many connections the given application has.

Screenshot from running a single prefect server start command with no configuration:
image

Screenshot from running PREFECT_SERVER_DATABASE_CONNECTION_APP_NAME='foobartest' prefect server start:
image

Screenshot with another PREFECT_SERVER_DATABASE_CONNECTION_APP_NAME='xxx' prefect server start --port 4300:
image


if self.sqlalchemy_max_overflow is not None:
kwargs["max_overflow"] = self.sqlalchemy_max_overflow

Copy link
Member Author

Choose a reason for hiding this comment

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

Also, I added these kwargs into our connection pools for non-memory SQLite as well; I couldn't find any reason why we should avoid configuring the pool for a SQLite DB.

Copy link

codspeed-hq bot commented Jan 11, 2025

CodSpeed Performance Report

Merging #16690 will not alter performance

Comparing add-app-name-to-conns (5bce05c) with main (3afbfb1)

Summary

✅ 2 untouched benchmarks

Copy link
Member

@desertaxle desertaxle left a comment

Choose a reason for hiding this comment

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

LGTM! A similar setting was proposed in #16374 also, so I'm sure this will be useful to users hosting their own server!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs enhancement An improvement of an existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants