Important
As of the 18.0.0 Rocky release, the functionality described below is only supported by the libvirt/KVM driver.
The file-backed memory feature in Openstack allows a Nova node to serve guest memory from a file backing store. This mechanism uses the libvirt file memory source, causing guest instance memory to be allocated as files within the libvirt memory backing directory.
Since instance performance will be related to the speed of the backing store, this feature works best when used with very fast block devices or virtual file systems - such as flash or RAM devices.
When configured, nova-compute
will report the capacity configured for
file-backed memory to placement in place of the total system memory capacity.
This allows the node to run more instances than would normally fit
within system memory.
When available in libvirt and qemu, instance memory will be discarded by qemu
at shutdown by calling madvise(MADV_REMOVE)
, to avoid flushing any dirty
memory to the backing store on exit.
To enable file-backed memory, follow the steps below:
Important
It is not possible to live migrate from a node running a version of OpenStack that does not support file-backed memory to a node with file backed memory enabled. It is recommended that all Nova compute nodes are upgraded to Rocky before enabling file-backed memory.
ram_allocation_ratio
must be set to 1.0
in nova.conf
, and the
host must not be added to a host aggregate with ram_allocation_ratio
set to anything but 1.0
.Handling these limitations could be optimized with a scheduler filter in the future.
Note
/dev/sdb
and the ext4
filesystem are used here as an example. This
will differ between environments.
Note
/var/lib/libvirt/qemu/ram
is the default location. The value can be
set via memory_backing_dir
in /etc/libvirt/qemu.conf
, and the
mountpoint must match the value configured there.
By default, Libvirt with qemu/KVM allocates memory within
/var/lib/libvirt/qemu/ram/
. To utilize this, you need to have the backing
store mounted at (or above) this location.
Create a filesystem on the backing device
# mkfs.ext4 /dev/sdb
Mount the backing device
Add the backing device to /etc/fstab
for automatic mounting to
/var/lib/libvirt/qemu/ram
Mount the device
# mount /dev/sdb /var/lib/libvirt/qemu/ram
Enable File-backed memory in nova-compute
Configure Nova to utilize file-backed memory with the capacity of the backing store in MiB. 1048576 MiB (1 TiB) is used in this example.
Edit /etc/nova/nova.conf
[libvirt]
file_backed_memory=1048576
Restart the nova-compute
service
Except where otherwise noted, this document is licensed under Creative Commons Attribution 3.0 License. See all OpenStack Legal Documents.