2 years ago
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!
0 Replies
2 years 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
2 years ago
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
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.
2 years 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
a year ago
Reviving this, as my MongoDB instance cusomes a lot of memory (around 24GB). While my whole database is taking 7GB of storage (collectins and indexes).
Since the instances have a 32GB RAM limit, it seems mongo is taking its ease and using a lot of it (https://www.percona.com/blog/mongodb-101-how-to-tune-your-mongodb-configuration-after-upgrading-to-more-memory/).
Would you have any insights or recommendations on how to optimize this?
Status changed to Solved brody • 10 months ago