Usage with AWS Lambda #520
Replies: 1 comment
-
For code that may or may not run in lambda I define a boolean In pool config I have used If you are using slonik as documented in the README the question of where and how it handles equivalent of The inside or outside question is a nuanced one imho because of how Lambda and other FaaS environments can keep variables defined outside the handler alive between invocations for the duration of the environment. The Prisma docs have some background on this https://www.prisma.io/docs/orm/prisma-client/setup-and-configuration/databases-connections#serverless-environments-faas and I recall AWS has some articles as well. With serverless you'd definitely want to use a connection pooler like RDS Proxy or PgBouncer to avoid exhausting your DB under load. |
Beta Was this translation helpful? Give feedback.
-
What is the recommended way to use this library with AWS Lambda? I am connecting to PgBouncer, which is running in transaction mode. I've run into some problems using the
pg
library directly in the past with connections not being closed.pool.end()
need to be explicitly called?Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions