N
Novu7mo ago
Naz

Connection to MongoDB closes occasionally in self-hosted novu

We are having issue with self-hosted novu. Connection to mongodb seem to close occasionally, resulting in increased app latency. Also I noticed that novu opens large number of connections to mongodb (up to around 500). Is this normal? Attached log message with 2 errors I frequently see in container logs. We are using novu 0.23.0
7 Replies
Ask Inkeep
Ask Inkeep7mo ago
Hi @Naz, I'm an AI assistant for Novu. While a team member reviews this question, I'll look through relevant sources and see if I can provide suggestions. Please tag @Ask Inkeep with any follow-up questions. ----------------------------- While I generate an answer, here are some sources that might be helpful: * Commercial Self Host * Deploy with Docker * Python * Blog Posts, Articles & Videos -----------------------------
Ask Inkeep
Ask Inkeep7mo ago
Answer The issue of Novu opening a large number of connections to MongoDB (up to around 500) and connections occasionally closing, resulting in increased app latency, is known and has been discussed in the context of a Novu deployment to Google Cloud with MongoDB Atlas. It was highlighted that such a high number of simultaneous MongoDB connections could be unexpected behavior, especially when the application is not performing significant operations (1) . However, the specific details related to version 0.23.0 and the errors you're encountering aren't directly covered in the provided information sources. For addressing issues related to database connections and potential solutions, such as configuring environment variables to manage connections better or scaling options, it would be advisable to refer to the official Novu documentation or consult with the Novu community for more specific guidance related to your version and deployment scenario.
Ask Inkeep
Ask Inkeep7mo ago
Got it. Tagging @Support for additional help.
Pawan Jain
Pawan Jain7mo ago
@Naz Mongodb connections can be managed using these environment variables
MONGO_MIN_POOL_SIZE
MONGO_MAX_POOL_SIZE
MONGO_MIN_POOL_SIZE
MONGO_MAX_POOL_SIZE
Naz
Naz7mo ago
@Pawan Jain Did you check the logs I attached? It is expected to get connection refusted error sometime or is this configuration issue on my side?
Pawan Jain
Pawan Jain7mo ago
@Naz I could find this on mongodb community related to error in log file https://www.mongodb.com/community/forums/t/replicasetnoprimary-when-attempting-to-connect-from-node/143013
Julian
Julian7mo ago
@Pawan Jain I don't think this is related. The MongoDB instance is located on a remote host. Vertically scaling the machine did not show much results in improvement either. I've checked through the history on both the Discord and Github and unable to located any similar problems. Do you have any ideas on waht could cause this issue to happen sporadically?
Want results from more Discord servers?
Add your server