From bd1c0b6749d6d284882f9cf69d2f479430852d3a Mon Sep 17 00:00:00 2001 From: Pete Bachant Date: Wed, 10 Jun 2026 06:26:14 -0700 Subject: [PATCH 1/2] Add to gitignore --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index c7be3fb4..e1078fb9 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,5 @@ node_modules/ /playwright/.cache/ .env .DS_Store +TODO.md +AGENTS_files From 3d355fc0950360d8629cf3389bcc2e00c3016fee Mon Sep 17 00:00:00 2001 From: Pete Bachant Date: Wed, 10 Jun 2026 06:35:15 -0700 Subject: [PATCH 2/2] Reduce db conn pool size and increase max conns --- backend/app/db.py | 5 ++++- docker-compose.yml | 3 +++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/backend/app/db.py b/backend/app/db.py index 6a6565e3..cb5c40dd 100644 --- a/backend/app/db.py +++ b/backend/app/db.py @@ -21,8 +21,11 @@ max_tries = 60 * 5 # 5 minutes wait_seconds = 1 +# Each worker process gets its own pool, so keep per-process limits modest: +# with 12 workers (8 backend + 4 backend-dvc), 5 + 5 = 10 per process gives a +# 120-connection worst case, comfortably under the db's max_connections (300). engine = create_engine( - str(settings.SQLALCHEMY_DATABASE_URI), pool_size=10, max_overflow=10 + str(settings.SQLALCHEMY_DATABASE_URI), pool_size=5, max_overflow=5 ) # make sure all SQLModel models are imported (app.models) before initializing DB diff --git a/docker-compose.yml b/docker-compose.yml index 4d545d55..9ea566d6 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -2,6 +2,9 @@ services: db: image: postgres:16 restart: always + # Raise the default max_connections (100) to accommodate per-worker + # connection pools across all backend processes. See backend/app/db.py. + command: ["postgres", "-c", "max_connections=300"] healthcheck: test: ["CMD-SHELL", "pg_isready -U ${POSTGRES_USER} -d ${POSTGRES_DB}"] interval: 10s