Skip to content

Reduce production DB connection burst during deploys#304

Open
ewlarson wants to merge 1 commit into
developfrom
feature/reduce-prd-db-connection-burst
Open

Reduce production DB connection burst during deploys#304
ewlarson wants to merge 1 commit into
developfrom
feature/reduce-prd-db-connection-burst

Conversation

@ewlarson

Copy link
Copy Markdown
Contributor

Summary

  • Set production DB_POOL_MIN=0 and DB_POOL_MAX=1 to avoid eager per-worker DB connections during web container startup.
  • Reduce production FastAPI workers from 4 public + 6 internal to 2 public + 2 internal.
  • Add a short comment explaining the rolling deploy connection-headroom constraint.

Why

The 0.8.9 deployment logs show FastAPI workers failing at startup with:

asyncpg.exceptions.TooManyConnectionsError: sorry, too many clients already

The production web container currently starts 10 FastAPI workers, and during a rolling deploy old and new containers overlap. Each worker creates its own DB pool, so startup can exceed Postgres connection headroom before the new container becomes healthy.

Validation

  • git diff --check
  • Verified asyncpg permits min_size=0 for pools.

No backend tests were run for this config-only change.

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.

1 participant