Janos Krnak
10/09/2025, 1:57 PMMarvin
10/09/2025, 1:57 PMMarvin
10/09/2025, 2:00 PM# Required DB URL (example uses asyncpg)
PREFECT_SERVER_DATABASE_CONNECTION_URL="<postgresql+asyncpg://user:pass@host:5432/dbname>"
# Connection pool tuning
PREFECT_SERVER_DATABASE_SQLALCHEMY_POOL_SIZE=20
PREFECT_SERVER_DATABASE_SQLALCHEMY_MAX_OVERFLOW=40
PREFECT_SERVER_DATABASE_SQLALCHEMY_POOL_TIMEOUT=30
PREFECT_SERVER_DATABASE_SQLALCHEMY_POOL_RECYCLE=1800
prefect.toml
[server.database]
connection_url = "<postgresql+asyncpg://user:pass@host:5432/dbname>"
[server.database.sqlalchemy]
pool_size = 20
max_overflow = 40
pool_timeout = 30
pool_recycle = 1800
To confirm your current values at runtime:
prefect config view --show-defaults
Docs
- Settings reference (including server/database nesting and env var names): Prefect 3 Settings reference
- Server database/SQLAlchemy settings (pool_size, max_overflow, pool_timeout, pool_recycle): Server database configuration (API reference)
Using PgBouncer
- You can place PgBouncer in front of your Postgres instance; it’s a common way to scale beyond the DB’s native connection limits. Choose a pooling mode that matches your workload and driver; session pooling is the most compatible, while transaction pooling offers higher density but can affect session-level features. Prefect does not require session state, but your broader environment might.
If you can share your target concurrency and database max_connections, I’m happy to suggest starting values for these settings.Janos Krnak
10/09/2025, 2:20 PMpool_size and max_overflow added? I can only see pool_recycle and pool_timeout when I do prefect config view --show-defaultsMarvin
10/09/2025, 2:20 PMexplore_module_offerings
📊 Tools used:
• check_cli_command (2x)
• explore_module_offerings (3x)
• read_github_issues (1x)
• research_prefect_topic (4x)
• search_github_discussions (1x)Janos Krnak
10/09/2025, 2:24 PMPREFECT_SERVER_DATABASE_SQLALCHEMY_POOL_RECYCLE='3600' (from defaults)
PREFECT_SERVER_DATABASE_SQLALCHEMY_POOL_TIMEOUT='30.0' (from defaults)
PREFECT_SQLALCHEMY_POOL_SIZE='5' (from defaults)Marvin
10/09/2025, 2:24 PMexplore_module_offerings
📊 Tools used:
• explore_module_offerings (1x)