What should I do if Memcached goes into the swap?

Hello,

Prompt how to be, if Memcached goes into the swap? The virtual machine is 7.2 CentOS, Nginx, Memcached, Php-fpm, MariaDB, and Bitrix. Resources allocated 8cpu, 12gb ram.

Configure memcached:
PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="1024"
OPTIONS="-l 127.0.0.1"

Use the command to find the process that most STOPAT:
for file in /proc/*/status ; do awk '/VmSwap|Name/{printf $2 "" $3}END{ print ""}' $file; done | sort -k 2 -n-r | less

memcached 99000 kB
mysqld 17052 kB

Also, I tried to check using vmstat and there appears periodically the values in columns si , so. In the end about the day the swap is hammered completely. I dumped the swap team, but for half of the day, he collects about 200 MB.

swapoff -a && swapon -a

total used free shared buff/cache available
Mem: 12G 5.8 G 631M 540M of 6.1 G 5.9 G
Swap: 1.0 G 163M 860M
July 9th 19 at 13:34
4 answers
July 9th 19 at 13:36
Solution
What should I do if Memcached goes into the swap?

  • To reduce swapiness.
  • To disable swap.


Predictable control when the app will go into swap, so on servers where this is undesirable, the swap easier to turn off. Of course when planning monitors and RAM other applications, so they do not gracilis.
July 9th 19 at 13:38
For 12GB RAM, the swap size to 1GB seems not enough.
But maybe the situation will save the parameter change swapinnes.
The first thing that came to Google: fx-files.ru/archives/704
July 9th 19 at 13:40
I think that swap on a server is only not the hood.
It depends on the tasks executed by the server. do you need the spare tire on a race car ?
on the car формулы1 definitely not.
in a rally car for Paris-Dakar definitely Yes.
Small business server kotoromi website and mail and dB with the books then do not worry that something will go underutilized in the swap but for other programs and commonly used files and memory.
The big server in the cluster with High Load - getting hot data in swap is equivalent to a drop server the arrival of oom-killera is neizbezhen, there Yes - swap is unnecessary. - dominique commented on July 9th 19 at 13:43
It is assumed that Menkes at this not spinning. - Damion.Upt commented on July 9th 19 at 13:46
July 9th 19 at 13:42
It's okay that Menkes put something in the swap - it is simply not necessary at the moment. You see that you have almost half the memory is not used, then in swap have fallen only because no longer used. Don't want to there something got - stupidly disable swap.

Find more questions by tags 1C-BitrixLinuxMemcachedSystem administration