Free up mongo memory?

Hi there! I'm running a Node app with MongoDB that works in "sessions". It's a web application but it stays idle most of the times. To avoid incurring in higher costs when it isn't required, I'm restarting the app every time a session ends and that takes care of the memory/caching of the node app itself. However, I haven't found a way to do the same for the MongoDB instance and was wondering if there was a way to restart the service or at least limit the memory usage from my node app, since that DB is mostly used as a cache for data that resides somewhere else. I understand this is an odd request but I thought it was worth asking!
5 Replies
Percy
Percy16mo ago
Project ID: b80fbea0-3f24-4fa5-ab1b-3d267f761495
TheOmegaBlack
TheOmegaBlackOP16mo ago
b80fbea0-3f24-4fa5-ab1b-3d267f761495
Brody
Brody16mo ago
you can manually restart it from within the plugin's settings, and to do it programmatically you'd have to call railway's api but it sounds like youd want to be flushing the session cache from the database instead of restarting it? it also kinda sounds like you have a memory leak with your node app
TheOmegaBlack
TheOmegaBlackOP16mo ago
Hey Brody, would flushing the session cache help reduce the memory usage? In that case how would I do that? Yeah, there might be some memory leaks inside the node app caused by websockets and a network unable to handle the number of devices. We might have a look if and when the client decides to update their infrastructure. I'm unable to get to the place and test things properly since I'm in a different country (and they won't hire anyone else to fix those issues, so). Restarting the app isn't ideal, but it works for now.
Brody
Brody16mo ago
- mongo keeps most recent data in memory, so if you remove the session from mongo after the user session ends, the memory may be released from mongo, as to how to program that, I don't know, ive never used mongo myself, but im sure the package you are using has documentation on how to remove data from mongo. - understandable
Want results from more Discord servers?
Add your server