1

I'm testing running monbodb on the kubernetes platform where I can limit the resources used by the running container.

Say I set the memory limit to 256Mb. The problem is that for example while making backup memory consumption increases to the limit and container gets restarted by kubernetes.

So the question is is there a way to limit mongodb memory consumption for my case so that it would not cause the crush by exeeding memory limit set by platform.

I could of course increase the limit but I'm interested in a principal solution and would like to understand this process better because I don't really now how memory consumed by mongodb and container os. Is it possible to tune mongodb/underlying linux os to work inside existing limits.

2

In normal situation, mongodb uses always all available memory!!

However, you can limit mongo's memory using cgroup.

Here is presentation what may help too.

7
  • What is all available memory? In terms of docker container?
    – WHITECOLOR
    Jul 10 '17 at 18:25
  • Means that that wiredTiger cache eats 50% of RAM minus 1 GB and all rest of free memory is used for filesystemCache. In normal situation mongodb expects that it is only application in the machine, that's why you don't run multiple mongod instances in one machine.. All of them try use all memory.
    – JJussi
    Jul 10 '17 at 18:39
  • Do you know what happens in case of running in docker container how does it determine available memory?
    – WHITECOLOR
    Jul 10 '17 at 18:42
  • I forgot to say, that cache (minimum) size is 256 MB, so more than 1024MB memory should be available. What comes to your question.. I haven't install mongodb on docker, but.. I though that it is normal Linux?!? So, mongod asks from OS how much memory is available and start using it.. ;-)
    – JJussi
    Jul 10 '17 at 18:46
  • 1
    And because in docker, you have other applications too, you must use cgroup and --wiredTigerCacheSizeGB to limit resources what mongod uses. (including cpu)
    – JJussi
    Jul 10 '17 at 18:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.