Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions src/lib/drizzle.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,12 +69,9 @@ function getReplicaUrl(): string {
}

// Primary pool - always points to Frankfurt (writes go here)
// max: 15 — keep low because Vercel can spawn 100+ concurrent serverless instances,
// each with its own pool, all hitting the same pgbouncer. At max:100, a cold-start
// cascade can open 100×N connections simultaneously and overwhelm pgbouncer.
export const pool = new Pool({
...getDatabaseClientConfig(postgresUrl),
max: 15,
max: 100,
connectionTimeoutMillis: Number.parseInt(POSTGRES_CONNECT_TIMEOUT || '30000'),
idleTimeoutMillis: 3000,
application_name: appName,
Expand All @@ -87,7 +84,7 @@ export const usesSeparateReplica = replicaUrl !== postgresUrl;
const replicaPool = usesSeparateReplica
? new Pool({
...getDatabaseClientConfig(replicaUrl),
max: 15,
max: 100,
connectionTimeoutMillis: Number.parseInt(POSTGRES_CONNECT_TIMEOUT || '30000'),
idleTimeoutMillis: 3000,
application_name: `${appName}-replica`,
Expand Down