• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Question How do i force my server to use more MEMORY and less SWAP?

Quinten

Regular Pleskian
Server operating system version
Ubuntu 18.04.5 LTS
Plesk version and microupdate number
18.0.46
Hello,

I just have a quick question about the memory usage and swap of one of my servers.
My swapiness is set at 10 yet my memory usage is so low how does this happen? (see attached image)

I have been told that swap needs to be on for Plesk , is still still accurate info?
 

Attachments

  • memory and swap.png
    memory and swap.png
    78.2 KB · Views: 23
Hi Igor,

Thank you for the reply.
I have seen this and my swapiness is at 10 in the file aswell and i have restarted.
 
The problem is because my swapiness is on 10 it should only start swapping when my in use ram is at 90 but as you see on the image this is not the case.
 
Files hold in swap aren't released easily. By design Linux prefers to keep files in swap, even if they aren't used. Because it's harder to get files in and out of swap than it is to keep them. If, for example, the swap space was already pretty occupied when you changed the Swapiness value to 10, the swap space won't suddenly get empty (Unless you've rebooted your system). It's useful to have a look at your Swapping throughput. It gives you some insight to when Swap is actually used.

Even if you set Swapiness to a low value, your system might still need swap space for certain tasks if there is not enough memory to run those tasks. That doesn't necessarily mean your memory is fully utilized however.

Remember, Swap is a good thing. It exists to help you run your system smoothly.

I have been told that swap needs to be on for Plesk , is still still accurate info?
This is incorrect. As noted in the Support article by @IgorG "Linux itself requires swap, not Plesk."
 
Last edited:
Files hold in swap aren't released easily. By design Linux prefers to keep files in swap, even if they aren't used. Because it harder to get files in and out of swap than it is to keep them. If, for example, the swap space was already pretty occupied when you changed the Swapiness value to 10, the swap space won't suddenly get empty (Unless you've rebooted your system). It's useful to have a look at your Swapping throughput. It gives you some insight to when Swap is actually used.

Even if you set Swapiness to a low value, your system still might need swap space for certain tasks if there is not enough memory for those tasks. That doesn't necessarily mean your memory is fully utilized. Remember, Swap is a good thing. It exists to help you run your system smoothly.


This is incorrect. As noted in the Support article by @IgorG "Linux itself requires swap, not Plesk."
I have rebooted the server last night and the swap usage went down (for now) but my real memory usage stayed almost the same :(
How can force plesk / linux to use more of the ram it clearly has available?
 

Attachments

  • memory.png
    memory.png
    139.6 KB · Views: 22
Your server is swapping a lot. Try to find out which process does that with the smem command.
This article explains how to use it:

TL;DR
# yum install smem
# smem -tp

This is a classic read on how Linux uses RAM:
Thank you for the reply and the info.
I have installed and run the command and i see alot of "php-fpm: pool WEBSITE"using around 1-2% swap each
Also the mysqld using about 2.5%
 

Attachments

  • smem -tp.png
    smem -tp.png
    4.1 KB · Views: 15
I had a lot of PHP-FPM static processes running but my question remains as to why swapping is used with these 2% each etc instead of the normal ram which according to the used value there is plenty of left?
 
Can you set swappiness to a lower value for a while and check if that reduces swap throughput?

By the way: I just noticed the size of the swapfile. Is that on purpose? I know Plesk recommends half the total memory size, but that might be why it uses swap that much.
 
Can you set swappiness to a lower value for a while and check if that reduces swap throughput?

By the way: I just noticed the size of the swapfile. Is that on purpose? I know Plesk recommends half the total memory size, but that might be why it uses swap that much.
Thank you for the suggestion
I have changed the swappiness from 10 to 1 and i will continue to monitor it this weekend.
And for the size yes i have just followed Plesk guidelines.

But just because the "ceiling" is so high it uses more and more? for normal memory i would understand just like how Linux uses all the memory nonetheless.
But for swap?
 
Can you set swappiness to a lower value for a while and check if that reduces swap throughput?

By the way: I just noticed the size of the swapfile. Is that on purpose? I know Plesk recommends half the total memory size, but that might be why it uses swap that much.
Hello I'm reporting back after the weekend.
Before the weekend i put the swappiness on 1 from 10 and it remains the same.

I really don't understand why it is not using my free ram and so much of the swap file.
 

Attachments

  • swap.png
    swap.png
    185.4 KB · Views: 14
I have servers running with swap off.

top - 21:33:17 up 54 days, 6:30, 1 user, load average: 2.30, 1.74, 1.65 Tasks: 169 total, 1 running, 167 sleeping, 0 stopped, 1 zombie %Cpu(s): 0.3 us, 0.1 sy, 0.0 ni, 99.6 id, 0.0 wa, 0.0 hi, 0.0 si, 0.0 st KiB Mem : 16265860 total, 4471940 free, 6799564 used, 4994356 buff/cache KiB Swap: 0 total, 0 free, 0 used. 7937496 avail Mem
 
With respect, I don't think swapiness works the way you think. The statement "The problem is because my swapiness is on 10 it should only start swapping when my in use ram is at 90 but as you see on the image this is not the case." isn't correct in linux. A swapiness of 10 doesn't mean 90% ram use before going to swap.

If you want the technical details of how swaping actually works (i.e. high and low water marks against zones) there is a really good article here Swapiness Overview at HowtoGeek , but tldr; essentially in the world of linux, swap use is not a bad thing :)

Hope this helps,
Justin
 
With respect, I don't think swapiness works the way you think. The statement "The problem is because my swapiness is on 10 it should only start swapping when my in use ram is at 90 but as you see on the image this is not the case." isn't correct in linux. A swapiness of 10 doesn't mean 90% ram use before going to swap.

If you want the technical details of how swaping actually works (i.e. high and low water marks against zones) there is a really good article here Swapiness Overview at HowtoGeek , but tldr; essentially in the world of linux, swap use is not a bad thing :)

Hope this helps,
Justin
I see! Thank you for the info.
I am not familiar with swap at all.

The link you send gave some clarity thank you!
 
Back
Top