-
-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Mongo Db Atlas data READ/WRITE becomes slower after 3 or 4 hours #15278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Without a repro script, there's no way we can reasonably repro this or make any informed recommendations. |
Here` is the index file for the node server There are 3 watch functions and a total of 16 collections The problem is that whenever I start or restart my server, the total number of connections is around 85. After some time, it rises to 160-180. However, after 4 to 5 hours of inactivity, the number of connections remains at 160-180, and any requests made afterward take longer to respond.
|
A potential explanation is the following code:
If you receive several Does your server receive multiple getNotifications events, or is getNotifications an event that gets received at most once per server? If multiple, you would move the |
The getNotifications event is called once every time a user logs in or opens an additional tab. But the problem isn't with the watch() functions, because I tested the server without the watch() function, and the same thing happened, so I don't think it is the issue. |
Ok, what about:
What's "Another Watch Function"? Also, I see a |
I added a reconnect parameter if needed any reconnect function but right now, I don't have any reconnect mechanism, the comment " Another Watch Function " is there not to say there is another watch function inside Trends.watch(), I'm, trying to say that it is just another watch function, total there is only 3 watch function |
Another possibility is that, given you have 4-5 hours of inactivity, the MongoDB driver's sockets are timing out. You might try setting |
This is how the code looks,
I am currently using a paid cluster in Atlas. I have monitored the RAM and CPU usage while this happens. The RAM and CPU are perfectly normal, but the data READ/WRITE process becomes slower, and the following event is triggered multiple times before this
mongoose.connection.on('disconnected', async () => {
console.log('MongoDB disconnected, attempting to reconnect...');
});
I am using node js with express
{
"mongoose": "^7.8.6",
"express": "^4.19.2",
}
the node version on the local system is v22.3.0
The text was updated successfully, but these errors were encountered: