From 35538dc0a40493c581321a55a9f897ad4654f4a0 Mon Sep 17 00:00:00 2001 From: Juan P Lopez Date: Tue, 5 Nov 2024 16:39:03 -0500 Subject: [PATCH] chore: update default mongodb connection settings --- core/api/src/servers/exporter.ts | 2 +- core/api/src/services/mongodb/index.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/api/src/servers/exporter.ts b/core/api/src/servers/exporter.ts index 9b67d7a179..963632b127 100644 --- a/core/api/src/servers/exporter.ts +++ b/core/api/src/servers/exporter.ts @@ -213,7 +213,7 @@ const main = async () => { setupMongoConnection({ syncIndexes: false, - options: { readPreference: "secondaryPreferred" }, + options: { readPreference: "secondaryPreferred", socketTimeoutMS: 120000 }, }) .then(() => main()) .catch((err) => logger.error(err)) diff --git a/core/api/src/services/mongodb/index.ts b/core/api/src/services/mongodb/index.ts index 11d9680ada..4a6c01df47 100644 --- a/core/api/src/services/mongodb/index.ts +++ b/core/api/src/services/mongodb/index.ts @@ -27,10 +27,10 @@ const DEFAULT_MONGODB_OPTIONS: mongoose.ConnectOptions = { compressors: ["snappy", "zlib"], maxPoolSize: 100, - minPoolSize: 20, - maxConnecting: 25, // Maximum number of concurrent connection attempts + minPoolSize: 15, + maxConnecting: 5, // Maximum number of concurrent connection attempts - socketTimeoutMS: 45000, // Close sockets after 45 seconds of inactivity + socketTimeoutMS: 60000, // Close sockets after 60 seconds of inactivity connectTimeoutMS: 15000, // Give up initial connection after 15 seconds serverSelectionTimeoutMS: 15000, // Keep trying to send operations for 15 seconds