fix(db): reduce overall number of db max conncetions to incr performance (#1575)

This commit is contained in:
Waleed
2025-10-08 00:30:44 -07:00
committed by GitHub
parent 7bdf0e94d7
commit ae3a7f0865
3 changed files with 8 additions and 25 deletions

View File

@@ -13,15 +13,15 @@ const connectionString = env.DATABASE_URL
const socketDb = drizzle(
postgres(connectionString, {
prepare: false,
idle_timeout: 10,
connect_timeout: 20,
max: 15,
idle_timeout: 20,
connect_timeout: 10,
max: 5,
onnotice: () => {},
}),
{ schema }
)
// Use dedicated connection for socket operations, fallback to shared db for compatibility
// Use dedicated connection for socket operations
const db = socketDb
// Constants

View File

@@ -11,8 +11,8 @@ const connectionString = env.DATABASE_URL
const db = drizzle(
postgres(connectionString, {
prepare: false,
idle_timeout: 15,
connect_timeout: 20,
idle_timeout: 20,
connect_timeout: 10,
max: 3,
onnotice: () => {},
}),

View File

@@ -10,28 +10,11 @@ if (!connectionString) {
throw new Error('Missing DATABASE_URL environment variable')
}
console.log(
'[DB Pool Init]',
JSON.stringify({
timestamp: new Date().toISOString(),
nodeEnv: process.env.NODE_ENV,
action: 'CREATING_CONNECTION_POOL',
poolConfig: {
max: 30,
idle_timeout: 20,
connect_timeout: 30,
prepare: false,
},
pid: process.pid,
isProduction: process.env.NODE_ENV === 'production',
})
)
const postgresClient = postgres(connectionString, {
prepare: false,
idle_timeout: 20,
connect_timeout: 30,
max: 30,
connect_timeout: 10,
max: 20,
onnotice: () => {},
})