Get the App
SLTechnology News&Howtos  ›  Internet Technology  › 

Redis inexplicable data is cleared problem troubleshooting record

Shulou Source: shulou.com Published: 2022-06-03 03:33:19 10月04日 Update

The new version of the system has just been released, and the values in the front-end feedback redis are often emptied. The first reaction is to suspect whose code has performed flushall or flushdb operations.

Track a wave through redis's monitor

Redis-cli-a "xxx" monitor if the redis is not configured with a password, you do not need to add the-a parameter. In practice, I added a > > / data/log/trace_redis.log to write all the operations into the file. Note that the log will be very large if the time is long.

Running down the redis will indeed be cleared, but no one / program has ever performed the flush operation, here pause for 5 minutes to think about life

Fortunately, a zabbix monitor was transferred here to monitor the memory usage of redis, and it was found that the memory usage of redis:

Redis will hit 10G for a short time, and then immediately fall, at this time, it can be determined that it should be related to memory, after reaching a certain threshold, the data is cleared.

To check the redis official website, there are detailed records: https://redis.io/topics/lru-cache

It is true that the document is checked down because reids has a memory limit, we have 10G here, and the clearing policy after having excess memory is all clear by default.

Open / etc/redis.conf (the actual path may be different)

This is it. Maxmemory sets the maximum memory usage of redis. After maxmemory-policy decides to exceed it, how to clear it?

Redis provides six data elimination strategies: 1. Volatile-lru: pick the least used data from the memory dataset with the expiration time set; 2. Volatile-ttl: select the data that is about to expire from the memory dataset with the expiration time set; 3. Volatile-random: randomly pick the data phase out from the memory dataset with the expiration time set 4. Allkeys-lru: select the least recently used data from the in-memory data set to be phased out; 5. Allkeys-random: randomly selected data from the data set to be phased out; 6. No-enviction (expulsion): banning the expulsion of data. (default phase-out policy. When the redis memory data reaches maxmemory, the OOM error is returned directly under this policy); for maxmemory setting, either by setting the maxmemory parameter in redis.conf, or by dynamically modifying the setting of the data elimination policy through the command CONFIG SET, by setting the maxmemory-policy parameter in redis.conf, or by dynamically modifying the command CONFIG SET

Of course, this is the strategy on redis. The actual tracking found that there is a program to redis all the way to the above phenomenon caused by push data, problem solving.

Tags: Data memory policy time parameters actual dynamic commands programs monitoring problems different large maximum subordinate no code front end password situation Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Huawei Shulou Technology macOS vpn Redmi