Skip to content

Commit ae3a7f0

Browse files
authored
fix(db): reduce overall number of db max conncetions to incr performance (#1575)
1 parent 7bdf0e9 commit ae3a7f0

File tree

3 files changed

+8
-25
lines changed

3 files changed

+8
-25
lines changed

apps/sim/socket-server/database/operations.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,15 @@ const connectionString = env.DATABASE_URL
1313
const socketDb = drizzle(
1414
postgres(connectionString, {
1515
prepare: false,
16-
idle_timeout: 10,
17-
connect_timeout: 20,
18-
max: 15,
16+
idle_timeout: 20,
17+
connect_timeout: 10,
18+
max: 5,
1919
onnotice: () => {},
2020
}),
2121
{ schema }
2222
)
2323

24-
// Use dedicated connection for socket operations, fallback to shared db for compatibility
24+
// Use dedicated connection for socket operations
2525
const db = socketDb
2626

2727
// Constants

apps/sim/socket-server/rooms/manager.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ const connectionString = env.DATABASE_URL
1111
const db = drizzle(
1212
postgres(connectionString, {
1313
prepare: false,
14-
idle_timeout: 15,
15-
connect_timeout: 20,
14+
idle_timeout: 20,
15+
connect_timeout: 10,
1616
max: 3,
1717
onnotice: () => {},
1818
}),

packages/db/index.ts

Lines changed: 2 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,11 @@ if (!connectionString) {
1010
throw new Error('Missing DATABASE_URL environment variable')
1111
}
1212

13-
console.log(
14-
'[DB Pool Init]',
15-
JSON.stringify({
16-
timestamp: new Date().toISOString(),
17-
nodeEnv: process.env.NODE_ENV,
18-
action: 'CREATING_CONNECTION_POOL',
19-
poolConfig: {
20-
max: 30,
21-
idle_timeout: 20,
22-
connect_timeout: 30,
23-
prepare: false,
24-
},
25-
pid: process.pid,
26-
isProduction: process.env.NODE_ENV === 'production',
27-
})
28-
)
29-
3013
const postgresClient = postgres(connectionString, {
3114
prepare: false,
3215
idle_timeout: 20,
33-
connect_timeout: 30,
34-
max: 30,
16+
connect_timeout: 10,
17+
max: 20,
3518
onnotice: () => {},
3619
})
3720

0 commit comments

Comments
 (0)