Swap space

On Linux, swap space is used when the physical memory (RAM) is full.

If the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space. Swappiness indicates how frequently a system should use swap space based on RAM usage. The swappiness range is from 0 to 100 where, by default, most Linux platforms have swappiness set to 60.

For optimal Couchbase Server operations, set the swappiness to 0 (zero).

To change the swap configuration:

  1. Execute cat /proc/sys/vm/swappiness on each node to determine the current swap usage configuration.
  2. Execute sudo sysctl vm.swappiness=0 to immediately change the swap configuration and ensure that it persists through server restarts.
  3. Using sudo or root user privileges, edit the kernel parameters configuration file, /etc/sysctl.conf, so that the change is always in effect.
  4. Append vm.swappiness = 0 to the file.
  5. Reboot your system.
Note: Executing sudo sysctl vm.swappiness=0 ensures that the operating system no longer uses swap unless memory is completely exhausted. Updating the kernel parameters configuration file, sysctl.conf, ensures that the operating system always uses swap in accordance with Couchbase recommendations even when the node is rebooted.