-3

occasionally my server hits 100% usage on virtual memory and I don't know if that is something alarming or not? ( this happends gradualy to fill to that percent over 1-2 weeks from clean swap)

I usually resolve this issue like this:

swapoff -a && swapon -a

do you suggest any other method of resolving this?

I tried to see what is in swap and clearly it's php-cgi or each sites processes that runs on my server..

after I run this:

for file in /proc/*/status ; do awk '/VmSwap|Name/{printf $2 " " $3}END{ print ""}' $file; done | sort -k 2 -n -r | less

I get this result:

miniserv.pl 17096 kB
php-cgi7.0 15732 kB
php-cgi7.0 15532 kB
php-cgi7.0 13768 kB
php-cgi7.0 13532 kB
php-cgi7.0 13300 kB
php-cgi7.0 12056 kB
php-cgi7.0 11004 kB
php-cgi7.0 9636 kB
php-cgi7.0 4712 kB
php-cgi7.0 3700 kB
php-cgi7.0 3600 kB
php-cgi7.0 3288 kB
php-cgi7.0 3100 kB
php-cgi7.0 3084 kB
php-cgi7.0 3040 kB
php-cgi7.0 2824 kB
php-cgi7.0 2756 kB
(sd-pam) 2580 kB
php-cgi7.0 2524 kB
php-cgi7.0 2524 kB
(sd-pam) 2280 kB
(sd-pam) 2192 kB
php-loop.pl 2076 kB
php-loop.pl 2076 kB
php-loop.pl 2072 kB
php-loop.pl 2072 kB
php-loop.pl 2072 kB
php-loop.pl 2072 kB
php-loop.pl 2072 kB
php-loop.pl 2072 kB
(sd-pam) 2036 kB
php-loop.pl 1976 kB
php-loop.pl 1964 kB
php-loop.pl 1964 kB
php-loop.pl 1964 kB
php-loop.pl 1960 kB
php-loop.pl 1956 kB
php-loop.pl 1956 kB
php-loop.pl 1948 kB
php-loop.pl 1940 kB
php-loop.pl 1920 kB
php-loop.pl 1908 kB
php-loop.pl 1908 kB
php-loop.pl 1904 kB
php-loop.pl 1872 kB
  • 1
    It is normal for OS to swap out unused code – AlexD May 22 '17 at 09:28
  • ok, do you suggest to do what I do now,, or not,, or maybe I don't have to do this `swapoff -a && swapon -a` at all,, would OS be fine to do maintanance on it's own? – Kresimir Pendic May 22 '17 at 09:31
  • 2
    You definitely don't need to switch swap off/on. It is good to have unused code swapped out as it frees much more valuable RAM. – AlexD May 22 '17 at 09:36
  • not your virtual memory, but your physical memory. – c4f4t0r May 22 '17 at 09:36
  • ok thanks for help guys,, I have much free SYS memory but I will stop to do that switching on/off for now and see how server goes from that.. – Kresimir Pendic May 22 '17 at 09:51
  • 2
    If you have a lot of free memory you can tune swappiness to get a bit of performance boost. See https://en.m.wikipedia.org/wiki/Swappiness – AlexD May 22 '17 at 10:35
  • 1
    yeah,,did that already ;) – Kresimir Pendic May 22 '17 at 11:47
  • Was going through this same issue with my 4GB RAM 256MB virtual memory server and I was worried since there was just one fresh wordpress site on the server until I read this: https://www.linuxatemyram.com/ – AndrewL64 Jun 08 '20 at 21:27

1 Answers1

1

Your question about swap, virtual memory it's sum of (RAM+Swap)*over-commitment. You could read more on in wiki.

You have problem with swap. I don't know why, but all Linux always swaps, and you couldn't do anythything. In your case, if you don't want use swap, you could increase vm.overcommit_ratio to prevent problems with Virtual Memory and remove swap at all.

Alexander Tolkachev
  • 4,513
  • 3
  • 14
  • 23