Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Redis inexplicable data is cleared problem troubleshooting record

2025-01-20 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >

Share

Shulou(Shulou.com)06/03 Report--

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.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Internet Technology

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report