Why should I care if my server is using swap?#
- Swap is slower than RAM
- Swap is written to SSD, which has a limited number of write cycles, while RAM is not
- You spent money on RAM, don’t waste it
Swappiness value#
- Range: 0-100
- Default: 60
- 0: Swap is used only when absolutely necessary
- 100: Swap is used as much as possible
Check swappiness value#
1
| cat /proc/sys/vm/swappiness
|
Change swappiness value#
Temporarily#
1
| sudo sysctl vm.swappiness=10
|
Permanently#
1
| sudo nano /etc/sysctl.conf
|
- Add/modify the following line
1
| sudo sysctl --load=/etc/sysctl.conf
|
References#
High swap usage on Ubuntu server | https://serverfault.com/a/1108210