dockerfile / mongodb

MongoDB Dockerfile for trusted automated Docker builds.
http://dockerfile.github.io/#/mongodb
MIT License
326 stars 234 forks source link

Respect container memory limits #34

Open rueberger opened 6 years ago

rueberger commented 6 years ago

Apologies if this isn't the best place for this issue.

I've noticed that with docker 17.12.0-ce and the mongo:3.4.1 image, memory limits imposed on the container are not "respected" by mongo. What I mean by this is that mongo seems to not recognize the memory limit and tries to use the full memory of the host system.

This leads to bad things happening when memory fills up - mongo starts spilling into swap and performance slows to a crawl.

I would rather not give mongo unrestricted access to the host's memory, or be forced to periodically kill mongod.

I considered explicitly limiting the cache size for WiredTiger, but that's no good because the file-system cache is still unbounded.

Any ideas for a workaround?

ronaldescalona commented 6 years ago

Hey @rueberger !

I'm working around this issue too, but I still looking for a workaround, without success. Perhaps, do you had found the way to fix this behaviour?

My lab on Kubernetes: Sharding Cluster: 1 replica set Config Servers (3 servers), 1 Shard (1 replica set, 3 servers + 2 arbiters) and 2 mongos.

Thanks, Ronald E.

rueberger commented 6 years ago

I haven't had any issues for a while, but I'm not really sure what changed. Now running mongo:3.6, with the following mongo.conf:

storage:
  dbPath: /data/db
  wiredTiger:
    engineConfig:
         cacheSizeGB: 6

and a container memory limit of 10G. Hope that helps.