Repository navigation
Make DB connection-pool size configurable via env - #10
Merged
Merged
Conversation
The per-process pool was hard-coded to min=5/max=40. Each running instance opens up to max connections per dbname, and on App Runner the service scales to MaxSize instances, so total connections to the Aurora cluster can be MaxSize × pool_max × (#dbnames). Expose RDS_POOL_MIN / RDS_POOL_MAX / RDS_STATEMENT_TIMEOUT_MS so this can be tuned against the cluster's max_connections (or capped when fronting with RDS Proxy) without a code change. Defaults are unchanged; min is clamped to max on misconfig. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Adds environment-variable configurability for the per-process RDS connection pool bounds and statement timeout in the API layer, allowing operational tuning of Aurora/RDS Proxy connection budgets without code changes.
Changes:
- Introduces a small
_env_inthelper to parse positive integers from env vars with warning logs on invalid values. - Makes
_POOL_MIN,_POOL_MAX, and_STATEMENT_TIMEOUT_MSconfigurable viaRDS_POOL_MIN,RDS_POOL_MAX, andRDS_STATEMENT_TIMEOUT_MSwhile keeping existing defaults (5 / 40 / 10000). - Clamps
RDS_POOL_MINdown toRDS_POOL_MAXwhen misconfigured and documents the connection-budget math inline.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Why
The per-process connection pool was hard-coded to
min=5 / max=40. Each running instance opens up tomaxconnections per dbname, and on App Runner the service scales toMaxSizeinstances, so worst-case connections to the Aurora cluster are:There was no way to tune this against the cluster's
max_connections(or cap it when fronting with RDS Proxy) without a code change.Change
RDS_POOL_MIN/RDS_POOL_MAX/RDS_STATEMENT_TIMEOUT_MSare now env-configurable via a small_env_inthelper.minis clamped tomaxon misconfiguration; invalid/clamped values are logged as warnings so a bad deploy is diagnosable instead of silently falling back.Review
Multi-agent adversarial review found no bugs (the
_env_intedge cases — blank/non-numeric/negative/zero/min>max — all resolve to a valid(minconn, maxconn)).Independent of the other PRs. The env vars are referenced by the
docs/apprunner-scaling-runbookPR.