Apologies for the messy title, I don't quite know how to correctly categorize it as I'm still investigating it.
I'm running an app with pm2 set to cluster mode and max instances. The app uses mongodb (via mongoose).
When running the app via pm2, the amount of mongod threads climbs consistently, starting from 80 threads and up to >999, causing server unavailability and unresponsiveness.
I have added kill_timeout: 6000 to ecosystem.config.js but it doesn't seem to have fixed the issue, as I manually have to restart mongod in order to reduce the amount of threads.
Below is the ecosystem.config.js file:
I have already made sure that in terms of the app code, the connection to mongoose happens in a server plugin (a piece of code that runs once on server startup) and the disconnection happens in a graceful shutdown hook that listens to SIGINT and SIGTERM
Apologies for the messy title, I don't quite know how to correctly categorize it as I'm still investigating it. I'm running an app with pm2 set to cluster mode and max instances. The app uses mongodb (via mongoose). When running the app via pm2, the amount of mongod threads climbs consistently, starting from 80 threads and up to >999, causing server unavailability and unresponsiveness.
I have added kill_timeout: 6000 to ecosystem.config.js but it doesn't seem to have fixed the issue, as I manually have to restart mongod in order to reduce the amount of threads. Below is the ecosystem.config.js file:
I have already made sure that in terms of the app code, the connection to mongoose happens in a server plugin (a piece of code that runs once on server startup) and the disconnection happens in a graceful shutdown hook that listens to SIGINT and SIGTERM