N
N
neothesilent2016-05-17 18:31:24
linux
neothesilent, 2016-05-17 18:31:24

What to do if Memcached goes into swap?

Hello,
Can you tell me what to do if Memcached goes into swap? The virtual machine is running CentOS 7.2, Nginx, Memcached, Php-fpm, MariaDB and Bitrix. Resources allocated 8cpu, 12gb ram.
memcached settings:

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

I use the command to find the processes that swap the most:
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

I also tried to check through vmstat and there periodically appear values ​​in the columns si , so. As a result, in about a day, the swap is completely clogged. I reset the swap with the command, but in half a day it gains about 200 mb.
swapoff -a && swapon -a
total        used        free      shared  buff/cache   available
Mem:            12G        5,8G        631M        540M        6,1G        5,9G
Swap:          1,0G        163M        860M

Answer the question

In order to leave comments, you need to log in

4 answer(s)
L
landergate, 2016-05-17
@neothesilent

What to do if Memcached goes into swap?

It is not possible to predictably control when an application goes into swap, so on servers where this is undesirable, it is easier to turn off swap. Of course, planning and monitoring the RAM of other applications so that they do not crash.

D
DuD, 2016-05-17
@DuD

For 12GB of RAM, a 1GB swap looks a bit small.
But perhaps the situation will be saved by changing the swapinnes parameter.
The first thing that came across in Google: fx-files.ru/archives/704

S
Sergey, 2016-05-17
@begemot_sun

I think that swap on the server is just not good.

Y
Yuri Chudnovsky, 2016-05-18
@Frankenstine

It's okay that memcash put something in the swap - it just doesn't need it at the moment. You yourself see that almost half of your memory is not used in any way, which means that it fell into the swap only because it has not been used for a long time. Do not want something to get there - stupidly turn off the swap.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question