2

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.

asked Jul 10, 2017 at 17:10

1 Answer 1

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.

answered Jul 10, 2017 at 18:12
7
  • What is all available memory? In terms of docker container? Commented Jul 10, 2017 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. Commented Jul 10, 2017 at 18:39
  • Do you know what happens in case of running in docker container how does it determine available memory? Commented Jul 10, 2017 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.. ;-) Commented Jul 10, 2017 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) Commented Jul 10, 2017 at 18:52

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.