@teamkeel/functions-runtime 0.375.0 → 0.375.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/database.js +13 -0
package/package.json
CHANGED
package/src/database.js
CHANGED
|
@@ -145,6 +145,19 @@ function getDialect() {
|
|
|
145
145
|
return new PostgresDialect({
|
|
146
146
|
pool: new InstrumentedPool({
|
|
147
147
|
Client: InstrumentedClient,
|
|
148
|
+
// Increased idle time before closing a connection in the local pool (from 10s default).
|
|
149
|
+
// Establising a new connection on (almost) every functions query can be expensive, so this
|
|
150
|
+
// will reduce having to open connections as regularly. https://node-postgres.com/apis/pool
|
|
151
|
+
//
|
|
152
|
+
// NOTE: We should consider setting this to 0 (i.e. never pool locally) and open and close
|
|
153
|
+
// connections with each invocation. This is because the freeze/thaw nature of lambdas can cause problems
|
|
154
|
+
// with long-lived connections - see https://github.com/brianc/node-postgres/issues/2718
|
|
155
|
+
// Once we're "fully regional" this should not be a performance problem anymore.
|
|
156
|
+
//
|
|
157
|
+
// Although I doubt we will run into these freeze/thaw issues if idleTimeoutMillis is always shorter than the
|
|
158
|
+
// time is takes for a lambda to freeze (which is not a constant, but could be as short as several minutes,
|
|
159
|
+
// https://www.pluralsight.com/resources/blog/cloud/how-long-does-aws-lambda-keep-your-idle-functions-around-before-a-cold-start)
|
|
160
|
+
idleTimeoutMillis: 120000,
|
|
148
161
|
connectionString: mustEnv("KEEL_DB_CONN"),
|
|
149
162
|
}),
|
|
150
163
|
});
|