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 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