Skip to content

Commit

Permalink
fix: compressor settings
Browse files Browse the repository at this point in the history
  • Loading branch information
dolcalmi committed Nov 5, 2024
1 parent 7e705e7 commit f524b20
Show file tree
Hide file tree
Showing 3 changed files with 259 additions and 225 deletions.
1 change: 1 addition & 0 deletions core/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
"prom-client": "^15.1.3",
"rate-limiter-flexible": "^5.0.1",
"redlock": "^5.0.0-beta.2",
"snappy": "^7.2.2",
"svix": "1.37.0",
"tiny-secp256k1": "^2.2.3",
"twilio": "^5.3.4",
Expand Down
22 changes: 14 additions & 8 deletions core/api/src/services/mongodb/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,27 @@ type SetupMongoConnectionArgs = {
options?: mongoose.ConnectOptions
}

const DEFAULT_MONGODB_OPTIONS = {
const DEFAULT_MONGODB_OPTIONS: mongoose.ConnectOptions = {
autoIndex: false,
maxPoolSize: 50,
minPoolSize: 10,
compressors: ["snappy", "zlib"],

maxPoolSize: 100,
minPoolSize: 20,
maxConnecting: 25, // Maximum number of concurrent connection attempts

socketTimeoutMS: 45000, // Close sockets after 45 seconds of inactivity
connectTimeoutMS: 20000, // Give up initial connection after 20 seconds
serverSelectionTimeoutMS: 10000, // Keep trying to send operations for 10 seconds
connectTimeoutMS: 15000, // Give up initial connection after 15 seconds
serverSelectionTimeoutMS: 15000, // Keep trying to send operations for 15 seconds

retryWrites: true,
writeConcern: {
w: "majority", // Wait for majority acknowledgment
j: true, // Wait for journal commit
wtimeout: 5000, // Write timeout
wtimeout: 10000, // Write timeout
},
maxConnecting: 10, // Maximum number of concurrent connection attempts
compression: ["snappy", "zlib"], // Enable compression

retryReads: true,
maxStalenessSeconds: 90,
readPreference: "primaryPreferred", // Prefer primary but allow secondary reads
readConcern: { level: "majority" }, // Read from majority-committed data
} as const
Expand Down
Loading

0 comments on commit f524b20

Please sign in to comment.