Question
Is the swap usage on my server too high?
Answer
You can verify your server's swap usage using the following command:
# free -h
total used free shared buff/cache available
Mem: 7.6G 894M 4.2G 361M 2.6G 6.1G
Swap: 2G 1.9G 0.1G
Swap usage alone is not an indication of an immediate issue. Swap usage is often associated with system performance problems because the majority of the time high swap usage occurs during and after the server has run low on memory. It's important to remember that it is not the usage of swap itself that is causing a problem. Quite to the contrary, the usage of swap is actually a good thing and can help to speed your server up.
Swap acts as a place to cache less frequently used data that would otherwise take up RAM. This makes it so that your server can keep the most highly trafficked data in RAM, but still have less frequently used data cached and ready to use from the swap space. Moving data to swap is a relatively slow and intensive task. The kernel will only move data to swap if it determines that the benefit outweighs the slow operation.
Ultimately, the amount of swap used should not be something to be concerned about.
If required, you can flush all of the used swap pages back into RAM and set your swap space back to 0.
To turn swap off, run the following command:
CPANEL_WARN: Please ensure that the swap space is already configured in /etc/fstab before running the following command. If it is not configured in /etc/fstab, the swap space may not automatically come back when running the swapon command.
# swapoff -a
To turn swap back on, run the following command:
# swapon -a
CPANEL_INFO: It is perfectly safe to run these commands as long as your server is not currently experiencing a low memory condition.
Comments
0 comments
Article is closed for comments.