1

The problem is that we have a huge dataset consists of 50 mln records and almost all fields are indexed, that causes huge consumption of RAM, and after collection is deleted resources are not released, I know that this can be solved by restarting the server, but this solution is not applicable under our situation. So, my question - is there a way to release RAM resources without restarting mongo server? Version of Mongo is 4.4. Thanks in advance.

1 Answers1

0

Not directly... MongoDB never make memory free, it just replaces it or allocates more. But if you start reading from the disk data what you're going to need, that data will replace that part of memory. Base problem is that MongoDB will always use (eventually) all free memory what is available and try to keep in memory all active data. So, reading data from the disk, makes that data "active" and will change the content of disk cache in the memory.

JJussi
  • 1,540
  • 12
  • 12
  • Thanks for the reply. Taking in consideration your comment, the idea of freeing memory is not an option, so is there any option to limitate the usage of ram? Assume i have 16 gb and i want mongo to consume maximum of 4 of it. I've tried an option for wired tiger called "cacheSizeGb" but with no luck for now. – Maksim Aristov Oct 22 '20 at 11:51
  • Yes... If you're using Unix (Linux), answer is 'cgroups'. – JJussi Oct 23 '20 at 12:27
  • Well, unfortuantelly our product will be spreaded across different systems, so, using this variant is not an option. But, we have found a solution that works just fine for now - using additional configurations, which is "configString":"cache_size=" for engine config, this allows us to restrict the amount of memory that is using. – Maksim Aristov Oct 27 '20 at 10:29