Problems with pg bouncer
javierfuentesm
HOBBYOP

2 years ago

I’ve been having a lot of problems with PgBouncer and Postgres. I have a backend that sends requests to an app hosted on Vercel, which uses serverless functions. After some connections, I start encountering a lot of errors.

I’ve already increased the number of connections to 1000 in Postgres and 2000 in PgBouncer, but I’m still experiencing the same issues.

Solved

39 Replies

javierfuentesm
HOBBYOP

2 years ago

609b9ed1-9979-4090-ae31-9e0ccb219a7a


2 years ago

what makes you think you are running into connection limits?


javierfuentesm
HOBBYOP

2 years ago

well the erro in vercel says that the database is nto approchable no ?


javierfuentesm
HOBBYOP

2 years ago

1316850621705359473


2 years ago

yeah but im not seeing anything that says you hit connection limits


2 years ago

unless im blind?


javierfuentesm
HOBBYOP

2 years ago

mm so what can it be? i thought those errors were referring to that


2 years ago

where do you see logs for connection limits?


javierfuentesm
HOBBYOP

2 years ago

well, I assumed it was a connection limit when Vercel showed me errors saying that I couldn't connect to the DB, that it was not reachable, and it only happens when I run a process that uses an API, and my understanding is that with Prisma it kind of creates one connection per serverless functions, if I run this locally it works because I have this , so it doesnt create one connection per request

1316855541682798602


2 years ago

how many times is the serverless function being invoked?


javierfuentesm
HOBBYOP

2 years ago

mm like 1000 times?


javierfuentesm
HOBBYOP

2 years ago

or less ?


javierfuentesm
HOBBYOP

2 years ago

i saw the errors were like ~800


2 years ago

may i ask, why not run app thats currently on vercel, on railway?


javierfuentesm
HOBBYOP

2 years ago

well, it started on Vercel, the free tier is "enough" for what we do, if I move it to Railway, it will cost me, and my understanding is that I will lose the serverless


javierfuentesm
HOBBYOP

2 years ago

and i get deployments on each PR , (I dont know if i get this with railway) also i can comemnt on the ui of the preview deployments


javierfuentesm
HOBBYOP

2 years ago

will i get any bennefit if i move it to railway ?


javierfuentesm
HOBBYOP

2 years ago

I'm reading this https://github.com/orgs/vercel/discussions/4539

But I'm not sure https://github.com/prisma/prisma/discussions/23589

they said that using &connection_limit=1 worked for them, but my understanding is that if I do this, the pgBouncer is pointless, no?


2 years ago

railway has both deploy from github pushes, and pr environments!

and you can always enable app sleep so your app goes to sleep and doesnt use any cpu / mem.

but above all, running your app on railway besides your database means that we wont have to charge you egress fees (as long as you use the private network)

also also, you wont need pgbouncer, so thats cost savings too


javierfuentesm
HOBBYOP

2 years ago

and who cna help me to migrate ?


javierfuentesm
HOBBYOP

2 years ago

sounds interesting because i have another app and i think im not using the private network


javierfuentesm
HOBBYOP

2 years ago

will i loose the serverless with nextjs correct?


javierfuentesm
HOBBYOP

2 years ago

how does that work ?


javierfuentesm
HOBBYOP

2 years ago

if the app has to be running because it is a web app


2 years ago

and who cna help me to migrate ?

you try to migrate, and if you get stuck, either me or another community member can help troubleshoot!

sounds interesting because i have another app and i think im not using the private network

its possible, you can open another thread for help with that

will i loose the serverless with nextjs correct?

yeah, railway is not serverless, though we do have app sleeping.

how does that work ?

if the app has to be running because it is a web app

your app runs 24/7


javierfuentesm
HOBBYOP

2 years ago

so what does the app sleep means ?


2 years ago


2 years ago

can't recommend it for anything other than a side project though


javierfuentesm
HOBBYOP

2 years ago

ok maybe i will try it so how will it work if it is not serverless, i will use for everything the same db connection?

also is there a way to help me to fix this issue ?


2 years ago

why does it have to be serverless?


2 years ago

what issue?


javierfuentesm
HOBBYOP

2 years ago

it doesnt , im just asking


javierfuentesm
HOBBYOP

2 years ago

with my db connection dying


2 years ago

i'm not sure about that, to fix it i had recommended running the app on railway


javierfuentesm
HOBBYOP

2 years ago

do you guys have a guide on how to migrate a next js project?


2 years ago

Should be pretty simple


javierfuentesm
HOBBYOP

2 years ago

and to use the internal db ? ,


2 years ago

use reference variables -


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...