Installation guide

Chapter 20.
161
Overcommitting with KVM
The KVM hypervisor supports overcommitting CPUs and overcommitting memory. Overcommitting is
allocating more virtualized CPUs or memory than there are physical resources on the system. With
CPU overcommit, under-utilized virtualized servers or desktops can run on fewer servers which saves
power and money.
Overcommitting memory
Most operating systems and applications do not use 100% of the available RAM all the time. This
behavior can be exploited with KVM. KVM can allocate more memory for virtualized guests than the
host has physically available.
With KVM, virtual machines are Linux processes. Guests on the KVM hypervisor do not have
dedicated blocks of physical RAM assigned to them, instead guests function as Linux processes. The
Linux kernel allocates each process memory when the process requests more memory. KVM guests
are allocated memory when requested by the guest operating system. The guest only requires slightly
more physical memory than the virtualized operating system reports as used. The Linux kernel swaps
infrequently used memory out of physical memory and into virtual memory. Swapping decreases the
amount of memory required by virtualized guests.
When physical memory is completely used or a process is inactive for some time, Linux moves the
process's memory to swap. Swap is usually a partition on a hard disk drive or solid state drive which
Linux uses to extend virtual memory. Swap is significantly slower than RAM due to the throughput and
response times of hard drives and solid state drives.
As KVM virtual machines are Linux processes, underused or idle memory of virtualized guests is
moved by default to swap. The total memory used by guests can be overcommitted, which is to use
more than the physically available host memory. Overcommitting requires sufficient swap space for all
guests and all host processes.
Without sufficient swap space for all processes in virtual memory the pdflush process, the cleanup
process, starts. The pdflush process kills processes to free memory so the system does not crash.
pdflush may destroy virtualized guests or other system processes which may cause file system
errors and may leave virtualized guests unbootable.This can cause issues if virtualized guests use
their total RAM.
Warning
If sufficient swap is not available guest operating systems will be forcibly shut down. This may
leave guests inoperable. Avoid this by never overcommitting more memory than there is swap
available.
Overcommitting with KSM
If KSM is used ensure the swap size is sufficient for the overcommitted RAM. KSM reduces
the RAM usage of identical or similar guests. Overcommitting guests with KSM without
sufficient swap may be possible but is not recommended. For more information on KSM and
overcommitting, refer to Chapter 21, KSM.