How to oversell KVM Memory KSM
Unlike OpenVZ virtualization, KVM is a full virtualization product which means you cannot oversell KVM some resources as standard. KVM nodes can oversell on CPU resources but you can’t oversell the space or the memory usage. This can cause issues with your available resources. For example, if you create a virtual server with 100GB of space and 10GB of ram. You will immediately notice 100GB of space is lost and 10GB of ram is also lost. This is quite wasteful because even though the new server will not be using 100GB of space or, anywhere near 10GB of ram. Those resources are no longer available for you to use.
Oversell KSM Memory
Firstly, before we proceed you cannot oversell KVM space on KVM nodes, it’s just not possible. However, you can oversell memory by using a little program called KSM (kernel same-page merging). KSM was originally developed by Red Hat and it’s been included since Kernel version 2.6.32. You can save between 30% to 60% of your memory resources by activating KSM. After an hour look at your resource usage. You should see a vast improvement in the resources that you have available to use.
To start KSM login to the host node as the root user and issue the below command to start KSM. Note, this should also start the ksmtuned service.
CentOS 7 systemctl start ksm CentOS 6 service ksm start
Ensure KSM is running by issuing the status commands
CentOS 7 systemctl status ksm systemctl status ksmtuned CentOS 6 service status ksm service status ksmtuned
To automatically start KSM on boot turn it on using the chkconfig script or systemctl
CentOS 7 systemctl enable ksm CentOS 6 chkconfig ksm on
You can use other switches with this script. Just swap start for the one required.
start stop restart force-reload condrestart try-restart status retune help
Extreme care should be taken when using KSM. If you overcommit to much your dedicated server / host will suffer problems. Only use KSM if you absolutely need it.
How was this article?
You might also like
More from Dedicated Servers
Cloud-init is a popular way to automate deployments of instances in a cloud or none cloud environment. To save having …
Ioncube Loaders are a piece of software that is used to protect the underlying code in PHP applications. Its aim …