Process kswapd0 increase cpu usage to 100%

Without doing anything else, my server has 100% cpu usage.

I don’t know why but when I type htop on root user CLI, I see kswapd0 using 90% of processor.

How to fix this problem ?

I already did this or anything else described here but after reboot, cpu become full used.

Happy New Year @mmngoms Happy you are here

You have an issue with swapiness which causing high cpu usage. This is cyberpanel unrelated.

Solution

Increase swappiness. This works on most ubuntu servers

$ swapoff /swapfile
$ rm  /swapfile
$ fallocate -l 8G /swapfile
$ chmod 600 /swapfile
$ mkswap /swapfile
$ swapon /swapfile

OR option I have used and borrowed from stackoverflow:

$ nano /home/drop_caches.sh
# add this to that file

cpu=$(/usr/bin/printf %.0f $(/bin/ps -o pcpu= -C kswapd0))

[[ -n $cpu ]] \
&& (( $cpu >= 90 )) \
&& echo 1 > /proc/sys/vm/drop_caches \
&& echo "$$ $0: cache dropped (kswapd0 %CPU=$cpu)" >&2 \
&& exit 1

exit 0


$ crontab -e
# add the a new cronjob at the end
  * *  *   *   *     /bin/bash /home/drop_caches.sh >> /var/log/syslog 2>&1

You can sink the cronjob anywhere else doesnt have to be /var/log/syslog