P
P
pingo2017-06-22 21:16:51
linux
pingo, 2017-06-22 21:16:51

Why does redis get into swap?

root# free -h
            total       used       free         shared    buffers     cached
Mem:            31G        31G       290M        38M       224M        28G
-/+ buffers/cache:       2.3G        29G
Swap:         4.0G       2.7M       4.0G

on an old server (centos 6, apache 2.4 prefork + php_opcache + mysql 5.5.3) the store is heavy enough to spin, everything seems to be fine, but there were lags with sessions, I switched sessions to redis, well, I liked it so much that I made a user tracker module to Redis(). recently radishes started getting into the swap, and some other demons. so I'm not an admin, knowledge is only necessary, tell me where to drip? what this server allows itself?
PID=1088 - Swap used: 0 - (ib_cm/3 )
PID=1093 - Swap used: 0 - (rdma_cm )
PID=1114 - Swap used: 0 - (ipoib_flush )
PID=1336 - Swap used: 132 - (auditd )
PID=1360 - Swap used: 92 - (portreserve )
PID=1441 - Swap used: 356 - (rsyslogd )
PID=1475 - Swap used: 124 - (irqbalance )
PID=1493 - Swap used: 132 - (dbus-daemon )
PID=1531 - Swap used: 108 - (acpid )
PID=1543 - Swap used: 416 - (hald )
PID=1544 - Swap used: 196 - (hald-runner )
PID=1576 - Swap used: 164 - (hald-addon-inpu )
PID=1589 - Swap used: 144 - (hald-addon-acpi )
PID=1603 - Swap used: 1264 - (redis-server )
PID=1715 - Swap used: 72 - (dovecot )
PID=1732 - Swap used: 0 - (pop3-login )
PID=1733 - Swap used: 0 - (lmtp )

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Cheremisin, 2017-06-22
@leahch

Most likely, your radish gobbled up all the available memory, and after that got into the swap.
Since the radish keeps everything exclusively in memory, it is advisable to delete the old keys. Well, if you use it exclusively for cache, then just run FLUSHDB or FLUSHALL, thereby cleaning all the keys at once. And perform these operations regularly, for example through a cron job.
In general, it is a good tradition to use TTL for keys so that they are deleted themselves after a certain time interval, but this is usually set programmatically for each key separately ... Yes, to set TTL, write session.gc_maxlifetime =
in php.ini
432000
This is 5 days in seconds, or how long you need to keep the session there ... Session keys will drop after this time and not pollute the memory.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question