Skip to content

Commit fd96e44

Browse files
improvement(sockets): increase buffer for connections (#695)
* increase sockets connection pool * correct comment
1 parent 4bb1237 commit fd96e44

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

apps/sim/db/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,12 @@ const connectionString = env.POSTGRES_URL ?? env.DATABASE_URL
1212
* Connection Pool Allocation Strategy
1313
*
1414
* Main App: 25 connections per instance
15-
* Socket Server: 3 connections total
15+
* Socket Server: 5 connections (operations) + 2 connections (room manager) = 7 total
1616
*
1717
* With ~3-4 Vercel serverless instances typically active:
1818
* - Main app: 25 × 4 = 100 connections
19-
* - Socket server: 3 connections
20-
* - Buffer: 25 connections
19+
* - Socket server: 7 connections total
20+
* - Buffer: 21 connections
2121
* - Total: ~128 connections
2222
* - Supabase limit: 128 connections (16XL instance)
2323
*/

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,11 @@ const connectionString = env.POSTGRES_URL ?? env.DATABASE_URL
1414
const socketDb = drizzle(
1515
postgres(connectionString, {
1616
prepare: false,
17-
idle_timeout: 10, // Shorter idle timeout for socket operations
18-
connect_timeout: 20, // Increase connection timeout for socket operations
19-
max: 2, // Very small pool for socket server to avoid exhausting Supabase limit
20-
onnotice: () => {}, // Disable notices
21-
debug: false, // Disable debug for socket operations
17+
idle_timeout: 10,
18+
connect_timeout: 20,
19+
max: 5,
20+
onnotice: () => {},
21+
debug: false,
2222
}),
2323
{ schema }
2424
)

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ const db = drizzle(
1313
postgres(connectionString, {
1414
prepare: false,
1515
idle_timeout: 15,
16-
connect_timeout: 20, // Increase connection timeout for room operations
17-
max: 1, // Minimal pool for room operations to conserve connections
16+
connect_timeout: 20,
17+
max: 2,
1818
onnotice: () => {},
1919
}),
2020
{ schema }

0 commit comments

Comments
 (0)