Overview
KVM and OpenVZ Virtualization provides the option to overcommit the physical memory. Most of the Memory assigned to a VPS is not being utilized fully and the remaining memory can be made free for other VPS.
Compatibility
Memory Overcommit option is only available for KVM and OpenVZ.
Example Scenario
If your dedicated server has 15GB memory, without memory overcommit, you can create 15 VPS of 1GB each. In this scenario if all the VPS is only utilizing 200MB of 1 GB assigned, then all the remaining 800MB from 15 VPS will not be utilized and left in the server.
Instead of wasting 800x15 = ~11GB, you can create new VPS with that remaining space. For Overcommiting the memory, you need to follow the below steps.
You can enable ksm and ksmtuned service on servers (apt-get install ksmtuned for Ubuntu/Debian servers if its not already present):
systemctl start ksm
//To enable the service on server boot
systemctl enable ksm
systemctl start ksmtuned
//To enable the service on server boot
systemctl enable ksmtuned
Reference : https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/virtualization_tuning_and_optimization_guide/chap-ksm
Kernel same-page merging (KSM) has a performance overhead which may be too large for certain environments or host systems.
systemctl stop ksmtuned
systemctl stop ksm
systemctl disable ksm
systemctl disable ksmtuned
Steps
To enable the memory overcommit, you need to update the memory limit in the configuration.
Go to Configuration > Slave Settings > RAM Overcommit
And set your required memory limit in MB.
Over-commit value to be displayed on create vps page is calculated based on Over-commit value set in slave settings on panel minus the total value of RAM assigned to all vpses from Admin panel (Can you be viewed in Servers->List Servers page)
If you have allotted 74000 MB out of 64000 MB (total RAM on server) while its actually using less RAM on server than allotted RAM to all of your vpses (50000MB) then you can 80000 as overcommit value so that you can view 16000MB free RAM for vps creation (irrespective of the actual free ram on server).
In all cases, server should have actual Free RAM to start the vps else it will always fail to start.
Value for RAM can go in negative if the total allotted RAM to all vpses crosses the over-commit value set in slave settings.
Note
- Memory overcommit depends upon the existing VPS utilization and free memory available in the server. We recommend to set the memory limit with respect to the memory utilized by all the VPS available (or will be created) in the server.
- Highly over-committed RAM can cause issues if vps actually start using RAM entirely which is assigned to them.
- The server host on which you want to overcommit RAM must have sufficient SWAP space present.
- Over-committing RAM is not recommended for production purpose and only advised for experienced admins