Pranav Sathyanarayanan
09/17/2022, 3:31 AMpgbouncer=true
flag on our connections. However our application still seems to be creating a connection pool of 2n+1
(so in our case 5 as these are 2 core machines) on our GCP Cloud Run applcation. I wanted to know:
1. What is the recommendation w.r.t to connection pooling in the application (Prisma) when we have pgBouncer configured. I was under the assumption that the application shouldn't pool connections at all and should opt rather to simply "request" a new connection (or create a new one) per query.
2. What happens if we set the connection_limit
to 0? Does this just disable application side pooling? The recommendation seems to be setting it to "1" however our intended behavior is that Prisma defers entirely to pgbouncer to supply connections on demand.
3. Prisma chunks large / complex queries into a series of SELECT statements one after the other. How does this behavior impact settings + usage of pgbouncer?
4. I assumed setting pgbouncer=true
should have disabled the client side application pool totally. I am still seeing (however) "timeouts" fetching a new connection with connection limit printing 5. Is that expected?Pranav Sathyanarayanan
09/17/2022, 3:43 AMconnection_limit=1
with pgbouncer=true
made it worse; now every query we make for our application (which usually results in multiple queries) has the error:
Error: 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: 1)
Nurul
09/27/2022, 4:00 PM1
for example will ensure Prisma will never run two queries in parallel but wait for the first one to finish before starting the second one.
What happens if we set theIt would consider the connection_limit as unlimited and not disable application side pooling.to 0?connection_limit
I am still seeing (however) “timeouts” fetching a new connection with connection limit printing 5. Is that expected?Can you enable metrics and check the connection pooling statistics?
Pranav Sathyanarayanan
09/28/2022, 1:57 PM2n+1
. The issue I was experiencing was actually cross-regional latency on GCP. The "Prisma" pool was still timing out because older connections were taking 10x longer than before as I had my pgBouncer. in a different region than the Cloud Run instance running Prisma.Nurul
09/30/2022, 12:11 PMPranav Sathyanarayanan
09/30/2022, 2:45 PMus-central1
hosting pgbouncer (simple config, connect to CloudSQL over Private IP). However our Cloud Run instance was in us-east1
. A simple latency test e2e (15 line nodejs app) showed that avg roundtrip latency for ~255ms for a simple SELECT uuid FROM user LIMIT 1
query when Cloud Run was communicating to GKE inter-region vs intra-region.
25ms over 100 queries (serial) us-east1 -> Serverless VPC Connector-> us-east1
255ms over 100 queries (serial) us-east1 -> Serverless VPC Connector -> us-central1Nurul
09/30/2022, 2:59 PM