For how long does Prisma keep idle connections aro...
# orm-help
j
For how long does Prisma keep idle connections around in the context of postgresql?
I found an undocumented parameter max_idle_connection_lifetime defaulting to 5m https://github.com/prisma/docs/issues/1657
Is it used today by prisma?
Because it’s been 5 min and we are still seeing our 3 idle connections
d
This setting may be a little confusing, the connections will not be immediately removed from the pool but they are lazily dropped and recreated if that connection is touched again if it exceeded that lifetime.
j
so if there is no activity on my server, the connections won’t be closed even after 5 min?
it’s the next time Prisma is doing something that it will cleanup the connections?
I thought there was a kind of setTimeout() somewhere that fired after 5min
d
prisma never actively closes connections (which has its own benefits and drawbacks) but in general, the closing of idle connections is a matter of db configuration for us right now.
the idle time just tells the prisma connection pool to reconnect after that idle time
this is needed for, say, google sql because they force close connection after a given time. to prevent failing queries we allow you to configure the pool so that we work around that
j
what’s the point of dropping + recreating the connection in one go? Shouldn’t connections be freed if not used after some time? If we set a max_connections at something like 10, will prisma eagerly open 10 connections and maintain those 10 connections all the time?
d
what’s the point of dropping + recreating the connection in one go? Shouldn’t connections be freed if not used after some time?
This directly relates to my previous message, it's about circumventing platform issues where databases kill connections after a given time, which would lead to intermittent issues if the pool hits a connection like that. The current pool does no asynchronous housekeeping, which is why everything is lazily evaluated when a connection is touched.
If we set a max_connections at something like 10, will prisma eagerly open 10 connections and maintain those 10 connections all the time?
The pool is not eagerly filled, only with more requests coming in will the pool increase in size until max is hit.
Shouldn’t connections be freed if not used after some time?
We have internal back and forth discussions about this. I can't disclose more right now, but we're actively discussion the pooling situation.