Question
Why is kswapd using so much CPU?
Answer
When running the top
command, you may find that the kswapd process is using an incredibly high amount of CPU usage. This issue generally happens when processes need to be moved to use swap instead of your free RAM.
A temporary measure for this issue would be to set drop_caches
to 1. This will tell the kernel to drop pagecache which will free up some of your memory. This should ideally prevent kswapd from needing to take any action. You can set the value with this command:
echo 1 > /proc/sys/vm/drop_caches
Ultimately, you should confer with a systems administrator or your web hosting provider to ensure your server has enough available RAM and that everything is configured properly. The following discussion regarding kswapd and CPU consumption may be useful as well: