mirror of
https://github.com/simstudioai/sim.git
synced 2026-01-09 15:07:55 -05:00
fix(db): enable database connection pooling in production (#1564)
* fix: enable database connection pooling in production * debug: add diagnostic endpoints to test NODE_ENV and database pooling * test: add connection testing endpoint to diagnose production delay * redeuce num of concurrent connections
This commit is contained in:
@@ -15,9 +15,8 @@ const socketDb = drizzle(
|
||||
prepare: false,
|
||||
idle_timeout: 10,
|
||||
connect_timeout: 20,
|
||||
max: 25,
|
||||
max: 15,
|
||||
onnotice: () => {},
|
||||
debug: false,
|
||||
}),
|
||||
{ schema }
|
||||
)
|
||||
|
||||
@@ -13,7 +13,7 @@ const db = drizzle(
|
||||
prepare: false,
|
||||
idle_timeout: 15,
|
||||
connect_timeout: 20,
|
||||
max: 5,
|
||||
max: 3,
|
||||
onnotice: () => {},
|
||||
}),
|
||||
{ schema }
|
||||
|
||||
@@ -14,16 +14,8 @@ const postgresClient = postgres(connectionString, {
|
||||
prepare: false,
|
||||
idle_timeout: 20,
|
||||
connect_timeout: 30,
|
||||
max: 80,
|
||||
max: 30,
|
||||
onnotice: () => {},
|
||||
})
|
||||
|
||||
const drizzleClient = drizzle(postgresClient, { schema })
|
||||
|
||||
declare global {
|
||||
// eslint-disable-next-line no-var
|
||||
var database: PostgresJsDatabase<typeof schema> | undefined
|
||||
}
|
||||
|
||||
export const db = globalThis.database || drizzleClient
|
||||
if (process.env.NODE_ENV !== 'production') globalThis.database = db
|
||||
export const db = drizzle(postgresClient, { schema })
|
||||
|
||||
Reference in New Issue
Block a user