Background: Production of a Redis server, physical memory 32G, several projects are in use, often less than a month memory will be exhausted, and then start to use Swap, when the swap is exhausted, the system will go down. The Redis configuration has also been optimized several times, but no results have been achieved. So I decided to look at the memory size of the Redis storage data to see if there are any abnormal data.
First, install redis-rdb-tools tools
# wget Https://github.com/sripathikrishnan/redis-rdb-tools/archive/master.zip
# Unzip Master
# CD redis-rdb-tools-master/
# python setup.py Install
Second, generate DUMP.RDB file Genetic memory report
Generate a memory report in CSV format. The included columns are: Database ID, data type, key, memory usage (byte), encoding. Memory usage contains key, value, and other values.
Note: Memory usage is approximate. In general, slightly lower than the actual value.
The content of the report can be filtered based on key or database ID or data type.
# rdb-c memory./dump.rdb > Redis_memory_report.csv
# sort-t,-k4nr redis_memory_report.csv
Submit the analysis results to the developer to confirm, and then find out that these data types are list key originally intended to do queue use, but the actual situation is not in. The list is growing in size, taking up more memory.
Remove a few memory-intensive keys and discover that the memory has been freed up in part:
Analyzing Redis memory usage with Redis-rdb-tools