How much swap should I allocate to the server? What kernel parameters should be used?
Use the following guidelines when deciding on how much disk space should be allocated to the swap partition on a PCS node:
|up to 4 GB||2 GB|
|4-16 GB||4 GB|
|16-64 GB||8 GB|
|64-256 GB||16 GB|
|256-512 GB||32 GB|
SWAP usage can be configured using the following parameters:
- Swappiness is used to define how aggressively the kernel swaps out anonymous memory relative to pagecache and other caches. Increasing the value increases the amount of swapping. The default value is 60.
- vfs_cache_pressure controls the tendency of the kernel to reclaim the memory which is used for caching of VFS caches, versus pagecache and swap. Increasing this value increases the rate at which VFS caches are reclaimed.
# sysctl -w vm.swappiness=20 # sysctl -w vm.vfs_cache_pressure=100
The values are approximate, you may change them according to your needs. To make these parameters permanent, add the corresponding lines to "
# grep vm /etc/sysctl.conf vm.swappiness = 20 vm.vfs_cache_pressure = 100
Note: decreasing SWAP usage will boost server performance only if the amount of physical RAM on the node is greater than the total amount of RAM allocated to containers and virtual machines.