Warning: This item maybe out of date WRT newer Linux kernels 5.0 and newer. A better solution maybe to use zram (and zswap) although that hasn't been evaluated by CSCF as of 2021-07-12

On hosts with plenty of memory, we want to reduce how aggressive the kernel is about swapping processes out.
By default swappiness=60, change the 10 below to 0 for lxc container IaaS (Infrastructure as a Service) containers or some other value but make sure you document your reasons/references in the sysctl.conf file!

echo -e "\n# \n# We have lots of memory so make system much less aggressive in swapping memory out to disk. \nvm.swappiness=10 \n" | sudo -s tee -a /etc/sysctl.conf

References:

  1. Linux Performance and Tuning Guidelines - IBM Redbooks
  2. What Is Swappiness on Linux? (and How to Change It) - Dec 2019
  3. Why most people recommend to reduce swappiness to 10-20? and the links it refers to
  4. Yoshinori's tutorial at the MySQL conference