I want to be able to control costs by limiting the...
# orm-help
k
I want to be able to control costs by limiting the number of DB connections withing the range of available connections in my cloud hosting plan. I would like to know whether Prisma either throws connections away or can it handle a connection pool. If it can, how can it be done.
r
@KJReactor 👋 I would suggest looking here for the format and this one is for Postgres. The
connection_limit
argument can be used to specify the maximum size of the connection pool. Also in production, it’s recommended to use a pooler like PgBouncer (for Postgres) that would help manage connections efficiently.
k
Thanks @Ryan . I read about this but was woundering if its sonething can out of the box
r
By out of the box, do you mean reusing connections? Could you explain a bit on that?
k
Yes. Usually, closing or disconnecting a db would simply mean throwing those unused connections away. With connection pools any application, in this case Prisma, will connect to any connections that are opened in the pool. Essentially connections are reused and there is a bit of a performance boost but it is more beneficial in terms of resources used.
Connection pools are set by setting the number of connections in the db's configs like in the link you sent me. I was hoping could handle that in some way since you can set the connection pool for postgres in the connection URL in scheme.prisma
r
That can be set only once I think. It cannot be dynamically changed.
k
Yes, but it was the the attempted connections I'm worried about
r
It will create a pool of those of connections and reuse those itself. Are you saying that the attempted connections will not be enough or would be more?
k
I am saying that I have reached max connection on my test machine before where subsequent attempts to connect simply failed. Therefore, if I need to use pools to avoid connection failures I would have to do this myself manually and directly to Postgres rather than through Prisma?
r
Yes. If that’s the case, then you would need to use something like PgBouncer so that it helps reuse the connections and will most likely prevent the max connection issues that you’re facing.
k
Ok thanks again for help!!
💯 1