Skip to content

Commit 2d83bbf

Browse files
improvement(db): further increase db limits (#696)
* increase sockets connection pool * correct comment * increase limits * remove comments
1 parent fd96e44 commit 2d83bbf

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

apps/sim/db/index.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,22 @@ const connectionString = env.POSTGRES_URL ?? env.DATABASE_URL
1111
/**
1212
* Connection Pool Allocation Strategy
1313
*
14-
* Main App: 25 connections per instance
15-
* Socket Server: 5 connections (operations) + 2 connections (room manager) = 7 total
14+
* Main App: 60 connections per instance
15+
* Socket Server: 25 connections (operations) + 5 connections (room manager) = 30 total
1616
*
1717
* With ~3-4 Vercel serverless instances typically active:
18-
* - Main app: 25 × 4 = 100 connections
19-
* - Socket server: 7 connections total
20-
* - Buffer: 21 connections
21-
* - Total: ~128 connections
22-
* - Supabase limit: 128 connections (16XL instance)
18+
* - Main app: 60 × 4 = 240 connections
19+
* - Socket server: 30 connections total
20+
* - Buffer: 130 connections
21+
* - Total: ~400 connections
22+
* - Supabase limit: 400 connections (16XL instance direct connection pool)
2323
*/
2424

2525
const postgresClient = postgres(connectionString, {
2626
prepare: false,
2727
idle_timeout: 20,
2828
connect_timeout: 30,
29-
max: 25,
29+
max: 60,
3030
onnotice: () => {},
3131
})
3232

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ const socketDb = drizzle(
1616
prepare: false,
1717
idle_timeout: 10,
1818
connect_timeout: 20,
19-
max: 5,
19+
max: 25,
2020
onnotice: () => {},
2121
debug: false,
2222
}),

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ const db = drizzle(
1414
prepare: false,
1515
idle_timeout: 15,
1616
connect_timeout: 20,
17-
max: 2,
17+
max: 5,
1818
onnotice: () => {},
1919
}),
2020
{ schema }

0 commit comments

Comments
 (0)