Search code examples
mysqlubuntuswap

Mysql 5.7 process shows a long time running, high memory swap


in some moments I have had to restart the server since the swap memory shows that it is out of space, I have been reviewing the activity using htop which has shown me that in mysql some processes are started and they last for hours consuming resources as if they will remain beginning and never end.

I appreciate if you can help me or give me an idea of ​​what I should do to improve this process.

Currently I have a machine with ubuntu server 18.04 which has mysql 5.7.1, apache 2.4.29 and php7.3 installed.

enter image description here


Solution

  • mysqld is a long running process so 9h is ok. Its threads as shown in htop have a more limited lifespan.

    Overall the mysql memory usage looks quite low (the amounts are for the main process, all threads use the main process amount).

    While there is some swap space used here it not excessively large. You only run out of swap space after you run out of memory. In the htop output here there is still lots of memory available. The brown is page cache, the OS's disk cache that is unused memory. Swap space usage when there is still ram available is ok, the OS will swap it out if there was a need.

    So in short, I can't see any problem here. It all, based on the information provided, looks quite normal and there is no immediate danger of out of memory or CPU.