Skip to content

Comments

Reduce Vercel DB pool sizes and enforce statement_timeout#518

Open
iscekic wants to merge 1 commit intomainfrom
fix/reduce-vercel-db-pool-sizes
Open

Reduce Vercel DB pool sizes and enforce statement_timeout#518
iscekic wants to merge 1 commit intomainfrom
fix/reduce-vercel-db-pool-sizes

Conversation

@iscekic
Copy link
Contributor

@iscekic iscekic commented Feb 24, 2026

Summary

  • Reduce pool max from 100 to 10 per pool (primary + replica) — at peak, dozens of warm Vercel instances across 20+ regions each holding max:100 connections contributes significantly to hitting the Supabase PgBouncer max_client_conn limit (3000).
  • Apply POSTGRES_MAX_QUERY_TIME as statement_timeout on the pool — the env var was validated to exist on startup but was never actually passed to the pool config.

Part of the fix for max_client_conn connection exhaustion (see also #497 for the Cloudflare worker changes).

- Reduce pool max from 100 to 10 per pool (primary + replica)
- Apply POSTGRES_MAX_QUERY_TIME as statement_timeout (was validated but never enforced)
@iscekic
Copy link
Contributor Author

iscekic commented Feb 24, 2026

This PR contains the Vercel Next.js app changes that were originally part of #497. They were split out so the Cloudflare worker changes (replacing pg.Pool with per-operation pg.Client to match the Hyperdrive pattern) could be reviewed and deployed independently from the Vercel pool size reduction.

@kiloconnect
Copy link
Contributor

kiloconnect bot commented Feb 24, 2026

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Notes

  • Pool size reduction from 100 → 10 is appropriate for Vercel's serverless model where many warm instances each hold connections.
  • Adding statement_timeout correctly wires up the POSTGRES_MAX_QUERY_TIME env var that was already validated at startup (line 18) but never actually passed to the pool config — good catch.
  • Both primary and replica pools receive identical changes, maintaining consistency.
Files Reviewed (1 file)
  • src/lib/drizzle.ts - 0 issues

@iscekic
Copy link
Contributor Author

iscekic commented Feb 24, 2026

Note to self - statement_timeout doesn't work

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