Skip to content

Commit 0c5e70f

Browse files
max 25 conc connections (#691)
1 parent bb75936 commit 0c5e70f

File tree

1 file changed

+12
-14
lines changed

1 file changed

+12
-14
lines changed

apps/sim/db/index.ts

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -11,25 +11,23 @@ const connectionString = env.POSTGRES_URL ?? env.DATABASE_URL
1111
/**
1212
* Connection Pool Allocation Strategy
1313
*
14-
* Main App (this file): 3 connections per instance
15-
* Socket Server Operations: 2 connections
16-
* Socket Server Room Manager: 1 connection
14+
* Main App: 25 connections per instance
15+
* Socket Server: 3 connections total
1716
*
1817
* With ~3-4 Vercel serverless instances typically active:
19-
* - Main app: 3 × 4 = 12 connections
20-
* - Socket server: 2 + 1 = 3 connections
21-
* - Buffer: 5 connections for spikes/other services
22-
* - Total: ~20 connections (at capacity limit)
23-
*
24-
* This conservative allocation prevents pool exhaustion while maintaining performance.
18+
* - Main app: 25 × 4 = 100 connections
19+
* - Socket server: 3 connections
20+
* - Buffer: 25 connections
21+
* - Total: ~128 connections
22+
* - Supabase limit: 128 connections (16XL instance)
2523
*/
2624

2725
const postgresClient = postgres(connectionString, {
28-
prepare: false, // Disable prefetch as it is not supported for "Transaction" pool mode
29-
idle_timeout: 20, // Reduce idle timeout to 20 seconds to free up connections faster
30-
connect_timeout: 30, // Increase connect timeout to 30 seconds to handle network issues
31-
max: 2, // Further reduced limit to prevent Supabase connection exhaustion
32-
onnotice: () => {}, // Disable notices to reduce noise
26+
prepare: false,
27+
idle_timeout: 20,
28+
connect_timeout: 30,
29+
max: 25,
30+
onnotice: () => {},
3331
})
3432

3533
const drizzleClient = drizzle(postgresClient, { schema })

0 commit comments

Comments
 (0)