Why it is discouraged to disable swap on a non-dedicated cluster

We are just starting out and would like to run a MongoDB replica set and a Docker swarm.
I wonder if I could fit them all on a 3-node cluster.

But, from the production notes:

If your MongoDB instance is hosted on a system that also runs other software, such as a webserver, you should choose the first swap strategy. Do not disable swap in this case.

Is it absolute? why? (Why should I not disable swap in this case?)

Says we have 4 GB nodes and limit cacheSizeGB to 0.5 GB (50% of (2GB - 1 GB)), isn’t it safe to use another 2GB to run containers without swap?

Hi @3Ji - Welcome to the community

Is it absolute? why?

I do not believe it is absolute. For example, if you are confident in your systems workload & memory usage and know for certain that swapping isn’t required, then swapping could possibly be disabled in this case.

One of the reasons that swapping is enabled is to help prevent the linux OOM killer from terminating the mongod instance. Perhaps you may wish to disable it if the OS the mongod instances are running on do not have a OOM kill function.

I’m not too familiar with Docker but I hope these details help.



This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.