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:
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.
and another error
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 lot1 Reply
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.