Postgres Connection Limit and Timeout
gitlherme
HOBBYOP

2 years 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

8 Replies

2 years 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


maddsua
HOBBY

2 years ago

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


2 years ago

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


gitlherme
HOBBYOP

2 years 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 🙂


2 years 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


gitlherme
HOBBYOP

2 years ago

True, I think that worked haha

Thanks a lot, @Brody!


2 years ago

no problem!


2 years ago

!s


Status changed to Solved brody over 1 year ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...