improvement(sockets): increase buffer for connections (#695)

* increase sockets connection pool

* correct comment
This commit is contained in:
Vikhyath Mondreti
2025-07-15 11:38:38 -07:00
committed by GitHub
parent 4bb1237027
commit fd96e446ae
3 changed files with 10 additions and 10 deletions

View File

@@ -12,12 +12,12 @@ const connectionString = env.POSTGRES_URL ?? env.DATABASE_URL
* Connection Pool Allocation Strategy
*
* Main App: 25 connections per instance
* Socket Server: 3 connections total
* Socket Server: 5 connections (operations) + 2 connections (room manager) = 7 total
*
* With ~3-4 Vercel serverless instances typically active:
* - Main app: 25 × 4 = 100 connections
* - Socket server: 3 connections
* - Buffer: 25 connections
* - Socket server: 7 connections total
* - Buffer: 21 connections
* - Total: ~128 connections
* - Supabase limit: 128 connections (16XL instance)
*/

View File

@@ -14,11 +14,11 @@ const connectionString = env.POSTGRES_URL ?? env.DATABASE_URL
const socketDb = drizzle(
postgres(connectionString, {
prepare: false,
idle_timeout: 10, // Shorter idle timeout for socket operations
connect_timeout: 20, // Increase connection timeout for socket operations
max: 2, // Very small pool for socket server to avoid exhausting Supabase limit
onnotice: () => {}, // Disable notices
debug: false, // Disable debug for socket operations
idle_timeout: 10,
connect_timeout: 20,
max: 5,
onnotice: () => {},
debug: false,
}),
{ schema }
)

View File

@@ -13,8 +13,8 @@ const db = drizzle(
postgres(connectionString, {
prepare: false,
idle_timeout: 15,
connect_timeout: 20, // Increase connection timeout for room operations
max: 1, // Minimal pool for room operations to conserve connections
connect_timeout: 20,
max: 2,
onnotice: () => {},
}),
{ schema }