P
Prisma4mo ago
Razil

Prisma & Supbase

Hello, im using Prisma for a NestJS REST project and im having some struggle with the connection pool. I enabled and exported the metrics related to prisma queries and performance and theres a scenario where randomly the open connections suddenly drop (screenshot at the bottom) Im currently using an Supabase XL instance:
Memory 16 GB
CPU 4-core ARM (Dedicated)
No. of direct connections 240
No. of pooler connections 1000
Max Disk Throughput 4,750 Mbps
Baseline Disk Throughput 1,188 Mbps
Memory 16 GB
CPU 4-core ARM (Dedicated)
No. of direct connections 240
No. of pooler connections 1000
Max Disk Throughput 4,750 Mbps
Baseline Disk Throughput 1,188 Mbps
and my connection string looks like this aws-0-us-east-1.pooler.supabase.com:6543/postgres?pgbouncer=true&connection_limit=80 Right now its set on connection_limit=80 since i noticed higher number makes it even more unstable (I tried go up to 140), another question i have, since the connection is pooler, i should be able to go up to 1000, correct? Unless im missing something, Im not sure how to achieve that since changing the the connection_limit seems related to direct connections.
Timed out fetching a new connection from the connection pool. More info: http://pris.ly/d/connection-pool (Current connection pool timeout: 10, connection limit: 80)
Timed out fetching a new connection from the connection pool. More info: http://pris.ly/d/connection-pool (Current connection pool timeout: 10, connection limit: 80)
and another error
Can't reach database server at `aws-0-us-east-1.pooler.supabase.com:6543`

Please make sure your database server is running at `aws-0-us-east-1.pooler.supabase.com:6543`.
prisma:error
Invalid `prisma.users.findUniqueOrThrow()` invocation:
Can't reach database server at `aws-0-us-east-1.pooler.supabase.com:6543`

Please make sure your database server is running at `aws-0-us-east-1.pooler.supabase.com:6543`.
prisma:error
Invalid `prisma.users.findUniqueOrThrow()` invocation:
Considering that the metrics reports 600-800 queries per sec, i think hit should hold way better and not get "pool timeout" where the 95th queries resolve at ~800 for the more demanding endpoint. Thanks a lot
No description
1 Reply
Razil
RazilOP4mo ago
In case someone else gets here
"Timed out fetching a new connection from the connection pool. More info: http://pris.ly/d/connection-pool (Current connection pool timeout: 10, connection limit: 80)" This error is referring to Prisma's internal pooler and not Supavisor.
I checked your metrics and it gave me the impression that you deployed Prisma to a single server. By default, Prisma will set the connection_limit to "num_cpus * 2 + 1". Prisma's query engine and internal pooler utilizes a lot of memory and CPU. When you changed the value significantly above the default, Prisma struggled to orchestrate requests.You would need to upgrade the server hosting Prisma or divide the workload across machines.
Want results from more Discord servers?
Add your server