You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've discovered that the pg adapter creates a Postgres connection and never releases it back to the pool.
I'm designing an app I'd like to run serverless, and I'm wondering if this will double the number of required connections. This will be my first serverless app.
My understanding is that in a serverless environment, state must not be shared across connections, and this seems to include the database connection pool. There are a number of articles on how to deal with database connection pooling in a serverless environment, such as this one, each indicating that the serverless function will indeed have to create a new connection on each request, but that it would delegate to an intervening tier that does the pooling of direct-to-database connections on the function's behalf.
If the pg adapter requires its own connection and my app needs a connection, each invocation of a serverless function would use two connections.
It seems to me that if the pg adapter instead only grabbed a connection from the pool when it needed it and released it to the pool each time after use, then my serverless functions could get away with one connection to the database per invocation. Both Lucia and my app would share a pool containing only one connection.
Is my understanding mistaken, or do we need to revise the use of connections in the pg adapter?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I've discovered that the pg adapter creates a Postgres connection and never releases it back to the pool.
I'm designing an app I'd like to run serverless, and I'm wondering if this will double the number of required connections. This will be my first serverless app.
My understanding is that in a serverless environment, state must not be shared across connections, and this seems to include the database connection pool. There are a number of articles on how to deal with database connection pooling in a serverless environment, such as this one, each indicating that the serverless function will indeed have to create a new connection on each request, but that it would delegate to an intervening tier that does the pooling of direct-to-database connections on the function's behalf.
If the pg adapter requires its own connection and my app needs a connection, each invocation of a serverless function would use two connections.
It seems to me that if the pg adapter instead only grabbed a connection from the pool when it needed it and released it to the pool each time after use, then my serverless functions could get away with one connection to the database per invocation. Both Lucia and my app would share a pool containing only one connection.
Is my understanding mistaken, or do we need to revise the use of connections in the pg adapter?
Beta Was this translation helpful? Give feedback.
All reactions