1

I have a server with 16GB RAM running several linux virtual machines (around 10), which perform several different tasks. These machines, with the default configuration, will fill up the memory I give them to the max with cache.

Even as this is a desirable behavior for physical hosts, on my setup, this cache is actually consuming real host RAM which is not freeable from the host, and forces me to set relatively low amounts of ram to the vms (no more than (16 - host cache)/number of vms). This is quite undesirable, as the system loses flexibility making impossible to handle sporadic requests of RAM from concrete vms.

The only approach that comes to my mind is to limit the amount of RAM the kernel can use for caching (or make cache expire sooner), but I haven't found any documentation on how to do it. Most forum posts refer to linuxatemyram.com or alike, and I haven't seem any relevant parameter exposed under /proc/sys/vm/ either.

Maybe some can offer some insights on this? I'd be really grateful.

  • 1
    It sounds like you are trying to overcommit memory. This is generally not a good idea. – Michael Hampton Feb 23 '17 at 14:50
  • It also sounds like you are trying to squeeze more out of the physical host than it can handle. You can't beat the laws of physics, at some point you have to get more resources in that machine. Having said that, have you tried to use KSM and balooning? – dyasny Feb 23 '17 at 18:52
  • You are correct, I plan to give the hosts more maximum RAM than the system has. This should't be a problem if cache usage is limited, as all the virtual machines using 100% of RAM is a very unlikely scenario. – Roberto Santalla Feb 24 '17 at 14:44
  • On the contrary, one or two GB RAM will be quickly used by a modern guest. The hypervisor has no way of knowing much of it is caches and can be reclaimed. You could try ballooning in the guest. In libvirt terminology, set currentMemory smaller than memory – John Mahowald Feb 25 '17 at 23:52
0

You can modify the value of /proc/sys/vm/vfs_cache_pressure to a value greater than 100 (default value). With increased value beyond 100, it causes the kernel to prefer to reclaim dentries and inodes.

  • Thanks for your response! Unfortunately, I've already tried to increase vfs_cache_pressure to 1000, and the results are still the same. All the available RAM is sucked by the cache in terms of five minutes. – Roberto Santalla Feb 24 '17 at 14:41

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.