Postgres Connection Limit and Timeout

gitlhermeHOBBY

3 months ago

Hello, I have a project on Railway with 2 services connected. A backend API using NestJS and Prisma ORM and a Postgres Database.

I'm connecting these two using the env variable {{ DATABASE_URL }} as a reference in internal network. But, sometimes, I receive the following error on my backend.

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: 97)

There is a possibility to adjust the connection pool and timeout on my database using the internal network? I know that I can using the public network, but I didn't found how to adjust using the internal network.

Can you please help me?

My project id is: 07d68a18-6f03-415d-a1c0-f353b7610ec3

Solved

0 Replies

3 months ago

There is a possibility to adjust the connection pool and timeout on my database using the internal network?

Hello, this would not have anything to do with the internal or public network, this would be a client side configuration in your database client


maddsuaHOBBY

3 months ago

Don't they need to throw pgbouncer in? Or can prisma handle that?


3 months ago

isnt pgbouncer mostly needed when the app is deployed to a serverless environment?


gitlhermeHOBBY

3 months ago

Hello, guys! Thanks for the answers!

In Prisma, I can handle with it just adding a query param in the end of the postgres url. For example

postgresql://postgres:postgres@postgres:5432/postgres?connection_limit=10

I'm defining that just 10 connectios are permitted to connect. But I can't handle it using the internal network variable I think, am I right?

But I will try to check another tools to do that like you guys said. Thanks a lot 🙂


3 months ago

yes you can, you'd use the exact same query parameter to the private url, I don't think you need pgbouncer at this point


gitlhermeHOBBY

3 months ago

True, I think that worked haha
Thanks a lot, @Brody!


3 months ago

no problem!


3 months ago

!s


Status changed to Solved brody 3 months ago