Problems with pg bouncer
javierfuentesm
HOBBYOP

a year 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

a year ago

609b9ed1-9979-4090-ae31-9e0ccb219a7a


a year ago

what makes you think you are running into connection limits?


javierfuentesm
HOBBYOP

a year ago

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


javierfuentesm
HOBBYOP

a year ago

1316850621705359400


a year ago

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


a year ago

unless im blind?


javierfuentesm
HOBBYOP

a year ago

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


a year ago

where do you see logs for connection limits?


javierfuentesm
HOBBYOP

a year 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

1316855541682798600


a year ago

how many times is the serverless function being invoked?


javierfuentesm
HOBBYOP

a year ago

mm like 1000 times?


javierfuentesm
HOBBYOP

a year ago

or less ?


javierfuentesm
HOBBYOP

a year ago

i saw the errors were like ~800


a year ago

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


javierfuentesm
HOBBYOP

a year 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

a year 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

a year ago

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


javierfuentesm
HOBBYOP

a year 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?


a year 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

a year ago

and who cna help me to migrate ?


javierfuentesm
HOBBYOP

a year ago

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


javierfuentesm
HOBBYOP

a year ago

will i loose the serverless with nextjs correct?


javierfuentesm
HOBBYOP

a year ago

how does that work ?


javierfuentesm
HOBBYOP

a year ago

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


a year 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

a year ago

so what does the app sleep means ?


a year ago


a year ago

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


javierfuentesm
HOBBYOP

a year 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 ?


a year ago

why does it have to be serverless?


a year ago

what issue?


javierfuentesm
HOBBYOP

a year ago

it doesnt , im just asking


javierfuentesm
HOBBYOP

a year ago

with my db connection dying


a year ago

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


javierfuentesm
HOBBYOP

a year ago

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


a year ago

Should be pretty simple


javierfuentesm
HOBBYOP

a year ago

and to use the internal db ? ,


a year ago

use reference variables -


a year ago

!s


Status changed to Solved brody over 1 year ago


Loading...