fix(db,deploy): fit connection budget inside Cloud SQL's max_connections=25 - #81
Merged
Conversation
…ons=25 Cloud SQL db-f1-micro has max_connections=25; with the previous pool_size=5 + max_overflow=10 at maxScale=5, peak demand was 75 — 3x the cap. The 2026-04-18 storm was driven by the Netlify sitemap generator bursting 18 parallel calls into that tight headroom. - app/database.py: pool_size=3, max_overflow=2 per process. - .github/workflows/deploy.yml: --max-instances=4 on the service update so the budget stays in lockstep with the pool config. Peak connections = 4 × 5 = 20, leaving ~5 slots for Postgres reserved roles and the migration job. Closes #79
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Root cause evidence (from `gcloud sql instances describe criticalbit-db` + `gcloud run services describe vagrant-story-api`):
Any moderately parallel traffic could exhaust the DB; the Netlify sitemap generator's 18-call burst (separately fixed in vagrant-story-web#152) was the reliable trigger.
Changes
New peak: 4 × (3 + 2) = 20 connections, leaving ~5 for Postgres reserved roles + the migration job.
Trade-offs
Future work (not in this PR)
Test plan
Closes #79