A newer version of this documentation is available.

View Latest

Swap space and kernel swappiness

On Linux, swappiness indicates how frequently the system uses the swap space based on its RAM usage.

Couchbase Server efficiently uses available RAM for your working set data; ideally, sufficient RAM remains available to the operating system even with your cluster’s configured Server RAM Quota as well. It is always a good idea to configure a reasonable amount of virtual memory or swap space on Linux-based nodes and a Pagefile on Windows. Sufficient virtual memory avoids that Couchbase Server processes from being killed by the OS, such as the Linux out of memory (OOM) killer.

The Linux kernel swappiness setting defines how aggressively the kernel will swap memory pages versus dropping pages from the page cache. A higher value increases swap aggressiveness while a lower value reduces swapping. The swappiness range is from 0 to 100, and most Linux distributions have swappiness set to 60 by default.

Set the swappiness setting to 0 (zero) or at most 1 for optimal Couchbase Server operation. The low range tells the kernel to swap as little as possible to disk and favor RAM. Couchbase Server is optimized with its managed cache to use RAM and is capable of managing what should be in RAM and what should not be. By allowing the OS to control what memory pages are in RAM, you lower Couchbase Server’s effectiveness.

To change the swappiness configuration:

  1. Execute

    cat /proc/sys/vm/swappiness

    on each node to determine the current swappiness configuration.

  2. Execute

    sudo sysctl vm.swappiness=0

    to change the swap configuration immediately.

  3. To ensure that this setting persists through the server restarts:

    1. Use sudo or root user privileges to edit the kernel parameters configuration file /etc/sysctl.conf, so that the change is always in effect.

    2. Append the following to the file:

      vm.swappiness = 0
    3. Reboot your system.

If you are making a golden master OS image or use a configuration automation system, do not forget to make this permanent change there too.
On Windows, there are no recommended virtual memory optimizations.