VPS of XEN and other architectures all have SWAP (SWAP partition ). When the physical memory is close to saturation, the system will automatically dump infrequently used memory files to SWAP. However, when the usage rate of SWAP is 30%, the system performance may be affected.
For VPS or servers with large physical memory, or based on your own server, you can manually disable or refresh the SWAP partition.
I. SWAP switch:
1. Disable SWAP
Generally used for servers with large physical memory
Swapoff-
Run the preceding command in SSH to disable the SWAP partition.
2. Enable SWAP
Swapon-
Run the preceding command in SSH to enable the SWAP partition.
Ii. Refresh SWAP
When the SWAP usage reaches 30%, the system performance may be affected. Therefore, we can execute the above two commands to refresh the SWAP (dumping the data in the SWAP back to the memory, and clear the data in SWAP)
Swapoff-a & swapon-
Execute the above command in SSH to achieve the corresponding purpose.
In fact, the principle of refreshing SWAP is to disable swap and restart it.