Process kswapd0 triggers 100% CPU usage

Posted April 1, 2020 24.3k views
DockerUbuntu 18.04


I installed the Docker Droplet of DO and loaded a modest docker-compose service.
After a week of working ok and uninterrupted for 8 days.

Suddenly cpu fired up to 100% usage and I couldnt access the droplet.
After reboot and password reset, I launched the process again and the same happed in a couple of hours.

The second time, I could enter to the droplet and doesn’t seems to be a hack on the machine. The process using the cpu was the kswapd0
and this is a known issue with the memory swap management but not very clearly solved in Ubuntu machines.

Furthermore, this is not really a machine, and I don’t know (and probably I don’t need to know) how is configured.

As this maybe is an trouble shared with other users I ask for some recommendation. Thanks in advance,
Willy Pregliasco

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
4 answers

Just for the record:
finally I the rebuild the project with the new swap configuration and everything it is going smoothing and with a 0.65% of CPU.

I learned that when the project runs low in memory, the operatives system can get corrupted and a fresh new start is a good advice.

Thanks for the help. See you in next troubleshot !


Hi there @willypregliasco,

It sounds like that you might not have enough RAM and the processes are moved to SWAP too frequently which could cause the high CPU load.

There are a few options that you can configure that will have an impact on your system’s performance when dealing with swap.

What I could suggest is tweaking your SWAP settings as described in this tutorial here:

Let me know how it goes!

If you are still facing the problem, can you share how much RAM you and how much SWAP space you’ve got as well? You can do that with this command here:

  • free -m

Hope that this helps!

by Justin Ellingwood
One of the easiest way of increasing the responsiveness of your server and guarding against out of memory errors in your applications is to add some swap space. In this guide, we will cover how to add a swap file to an Ubuntu 16.04 server. <$>[warning] [label...

Hi @bobbyiliev !

Thank you for your fast and acurate response.

The link you sent me is very clear and I could change the swap parameters understanding what I was doing.

Before the changes my system had:

par value
memory 1Gb
swap 0B
swapiness 60
cache pressure 50

Then, I changed everything and leaved as:

par value
memory 1Gb
swap 1.5Gb
swapiness 10
cache pressure 50


on reboot, again I have the kswapd0 with 98% of the CPU.

Please, tell me if you have any new idea. I think the system may be corrupted and it would be better to begin with a fresh new install. What do you think?

Thanks, is good to know there is somebody out there trying to help, I really appeciate that.

  • Sorry, there is a mistake in the first table: the cache-pressure before the changes was 100.

    After some hours of working server, CPU remains at 100% but the program is still doing well and the way the computer uses resources is more relaxed. I begin to suspect that the problem now is just that the memory assigned is low for this server. The point I don’t understand is why it worked so good the first 8 days.

    • Hi there @willypregliasco,

      Indeed I think that you are correct.

      Regarding the sudden change, this could be either due to the increase in traffic to your server for example or maybe some recent Kernel updates.


Show answer This answer has been marked as resolved by kfrank23.