New RHEL6-based OpenVZ kernel has a new memory management model, which supersedes User BeanCounters. After dragging my feet for a long time I decided to convert my running OpenVZ containers to the newer VSwap enabled scheme. Using VSwap makes the management and tracking of the old user beancounters a whole lot easier:
- Only the RAM and Swap parameters are mandatory in any container’s configuration
- Previous beancounters (container parameters) remain usable but are optional
Use following snippet to update the container config file:
Unfortunately the VSwap schema breaks the vzmemcheck utility as most its output is now complete unusable due to its many decimals introduced into its memory counters. A more modest AWK script called vzoversell tries to close that gap.
Using the new tool
vzmemcheck displays strange values for VSwap enabled containers):
A first version of vzoversell utility is added. This is a proposed vzmemcheck replacement for VSwap mode. Currently it just summarizes RAM and swap limits for all VSwap containers, and compares it to RAM and swap available on the host. Surely you can oversell RAM (as long as you have enough swap), but sum of all RAM+swap limits should not exceed RAM+swap on the node, and the main purpose of this utility is to check that constraint.
There is a new parameter
vm_overcommit, and it works in the following way – if set, it is used as a multiplier to ram+swap to set privvmpages. In layman terms, this is a ratio of real memory (ram+swap) to virtual memory (privvmpages). Again,
physpages limits RAM, and
swappages limits real memory used by a container. On the other side,
privvmpages limits memory allocated by a container. While it depends on the application, generally not all allocated memory is used – sometimes allocated memory is 5 or 10 times more than used memory. What
vm_overcommit gives is a way to set this gap.
I used it for following containers: