Why set minimum RAM when you have Ballooning + KSM enabled?

harmonyp

Member
Nov 26, 2020
195
4
23
46
I am a little confused by what the purpose of setting minimum RAM is when you have ballooning + KSM enabled.

If a virtual machine has 1024/2048 it can always use 2GB of that and even if it was using 512MB it would show the exact same usage either way (on the VM + Overall node usage)

I've been told it allows overselling but that's exactly what ballooning + KSM does so I am not sure if I should set minimum RAM. Can someone please explain the advantages/disadvantages.

One disadvantage I have come across when setting the memory low is Linux machines don't show the correct memory (top) and sometimes show no memory errors so I am thinking about removing it.
 
Last edited:
As far as I understand ballooning only works if your RAM of the host it over 80% used and it will only limit guests RAM between min and max if you set a min value. KSM will also start at 80% RAM usage by default config but you can change that.
 
Last edited:
As far as I understand ballooning only works if your RAM of the host it over 80% used and it will only limit guests RAM between min and max if you set a min value. KSM will also start at 80% RAM usage by default config but you can change that.
So setting the minimum low only lets you not use KSM faster? What's the advantage of that?

But Ballooning doesn't go towards the 80%? If the total nodes RAM is 32GB and you give 10 virtual machines 1024/4096 OR 4096/4096 but none of them are actually using more than 1GB then the total usage will still be 10GB (1/3 of total RAM)???
 
So setting the minimum low only lets you not use KSM faster? What's the advantage of that?

But Ballooning doesn't go towards the 80%? If the total nodes RAM is 32GB and you give 10 virtual machines 1024/4096 OR 4096/4096 but none of them are actually using more than 1GB then the total usage will still be 10GB (1/3 of total RAM)???
No, I mean balooning changes the available maximum usable RAM of the guests. If you set a VM to min=1GB and max=4GB ballooning will do nothing until your hosts RAM is 80% full. After that it will limit the maximum usable RAM of the guest from 4GB down to 1GB. If you set min=2GB the guests maximum usable RAM will change between 2GB and 4GB. If you don't set a lower min RAM value it shouldn't balloon at all.

KSM is another thing that works independently but is also preconfigured not to work until your hosts RAM exceeds 80% usage.

If the total nodes RAM is 32GB and you give 10 virtual machines 1024/4096 OR 4096/4096 but none of them are actually using more than 1GB then the total usage will still be 10GB (1/3 of total RAM)???
Until more then 25,6GB (80%) of you hosts RAM is used all 10 VMs will have a maximum 4GB RAM in the guest OS. If your hosts RAM exceeds 25,6GB the ballooning starts working and will limit your guests maximum RAM. If set to 1024/4096 and the ballooning ratio is everywhere the same, then it should set the max RAM of all of your guests to 3,2GB. Id you set it to 4096/4096 nothing should happen because no guest is allowed to have less that 4GB RAM.
 
Last edited:
  • Like
Reactions: harmonyp
No, I mean balooning changes the available maximum usable RAM of the guests. If you set a VM to min=1GB and max=4GB ballooning will do nothing until your hosts RAM is 80% full. After that it will limit the maximum usable RAM of the guest from 4GB down to 1GB. If you set min=2GB the guests maximum usable RAM will change between 2GB and 4GB. If you don't set a lower min RAM value it shouldn't balloon at all.

KSM is another thing that works independently but is also preconfigured not to work until your hosts RAM exceeds 80% usage.


Until more then 25,6GB (80%) of you hosts RAM is used all 10 VMs will have a maximum 4GB RAM in the guest OS. If your hosts RAM exceeds 25,6GB the ballooning starts working and will limit your guests maximum RAM. If set to 1024/4096 and the ballooning ratio is everywhere the same, then it should set the max RAM of all of your guests to 3,2GB. Id you set it to 4096/4096 nothing should happen because no guest is allowed to have less that 4GB RAM.
Thanks for the reply I get the first part now.

I am confused by the part where you said no guest will have less than 4GB of RAM if set to 4096/4096. If that's true then what's the point of enabling ballooning at all? I have read up on ballooning and from what I understand rather than if a VM uses up the whole 4GB and remains cached ballooning will basically clear the cache and give the RAM back to the host once finished?
 
Memory ballooning (KVM only) allows you to have your guest dynamically change it’s memory usage by evicting unused memory during run time. It reduces the impact your guest can have on memory usage of your host by giving up unused memory back to the host.

The Proxmox VE host can loan ballooned memory to a busy VM. The VM decides which processes or cache pages to swap out to free up memory for the balloon. The VM (Windows or Linux) knows best which memory regions it can give up without impacting performance of the VM.
Ballooning frees up cached stuff in the guests RAM because it forces it by lowering the RAM available to that VM. If the VM got 4GB RAM available and processes use 1GB of RAM the VM will use the remaining 3GB of RAM for caching. If ballooning kicks in and lower the available RAM of the VM from 4 to 2 GB, the VMs needs to free up half of its RAM so it can be removed from that VM. So ballooning basically changes the size of the available RAM.
 
Last edited:
Ballooning frees up cached stuff in the guests RAM because it forces it by lowering the RAM available to that VM. If the VM got 4GB RAM available and processes use 1GB of RAM the VM will use the remaining 3GB of RAM for caching. If ballooning kicks in and lower the available RAM of the VM from 4 to 2 GB, the VMs needs to free up half of its RAM so it can be removed from that VM. So ballooning basically changes the size of the available RAM.
Thank you for your reply.
If I understand correctly, the free up process does not happen when the RAM is set to 4096/4096. So 4096/4096 is equivalent to disabling the ballooning?
 

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!