Skip to content

Reduce db conn pool size and increase max conns#630

Merged
petebachant merged 2 commits into
mainfrom
too-many-clients
Jun 10, 2026
Merged

Reduce db conn pool size and increase max conns#630
petebachant merged 2 commits into
mainfrom
too-many-clients

Conversation

@petebachant

Copy link
Copy Markdown
Member

In response to a too many clients error.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts PostgreSQL connection limits and SQLAlchemy per-process pooling to mitigate “too many clients” errors in the backend stack.

Changes:

  • Increase Postgres max_connections to 300 in docker-compose.yml.
  • Reduce SQLAlchemy pool_size/max_overflow to 5/5 per worker process in backend/app/db.py.
  • Add TODO.md and AGENTS_files to .gitignore.

Reviewed changes

Copilot reviewed 2 out of 3 changed files in this pull request and generated 1 comment.

File Description
docker-compose.yml Raises Postgres max_connections to better tolerate aggregate connections across multiple worker processes.
backend/app/db.py Lowers per-process SQLAlchemy pool limits to reduce total concurrent DB connections across workers.
.gitignore Ignores local TODO/agent-generated artifacts.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread backend/app/db.py
Comment on lines +24 to +26
# 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).
@petebachant petebachant merged commit 7e2a605 into main Jun 10, 2026
7 of 8 checks passed
@petebachant petebachant deleted the too-many-clients branch June 10, 2026 14:49
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